-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python Fault Handling #22
base: master
Are you sure you want to change the base?
Changes from all commits
256bcc7
559b5ec
6ede4f5
b9c1ba9
d3bf4f1
7e6c6fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import faulthandler | ||
from .cpp_bindings import * | ||
|
||
faulthandler.enable() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -952,9 +952,9 @@ class BFIndex | |
} | ||
}; | ||
|
||
PYBIND11_PLUGIN(hnswlib) | ||
PYBIND11_PLUGIN(cpp_bindings) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this change the name of the module / what does this change do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this changes the name of the python bindings package |
||
{ | ||
py::module m("hnswlib"); | ||
py::module m("cpp_bindings"); | ||
|
||
py::class_<Index<float>>(m, "Index") | ||
.def(py::init(&Index<float>::createFromParams), py::arg("params")) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,10 @@ | |
include_dirs = [ | ||
pybind11.get_include(), | ||
np.get_include(), | ||
"./hnswlib", | ||
] | ||
|
||
# compatibility when run in python_bindings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just for my understanding - why is this ok to remove? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was additional complexity for if you wanted to run setup.py inside the |
||
bindings_dir = "python_bindings" | ||
if bindings_dir in os.path.basename(os.getcwd()): | ||
source_files = ["./bindings.cpp"] | ||
include_dirs.extend(["../hnswlib/"]) | ||
else: | ||
source_files = ["./python_bindings/bindings.cpp"] | ||
include_dirs.extend(["./hnswlib/"]) | ||
source_files = ["./python_bindings/cpp_bindings/bindings.cpp"] | ||
|
||
|
||
libraries = [] | ||
|
@@ -31,7 +25,7 @@ | |
|
||
ext_modules = [ | ||
Extension( | ||
"hnswlib", | ||
"hnswlib.cpp_bindings", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for my understanding - is this the module path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is the module path for the extension module being added here, in this case the cpp bindings are now a submodule of the hnswlib module |
||
source_files, | ||
include_dirs=include_dirs, | ||
libraries=libraries, | ||
|
@@ -127,4 +121,6 @@ def build_extensions(self): | |
install_requires=["numpy"], | ||
cmdclass={"build_ext": BuildExt}, | ||
zip_safe=False, | ||
package_dir={"hnswlib": "python_bindings"}, | ||
packages=["hnswlib"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is the rexport that makes everything appear under hnswlib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes