diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56c93ef7..37c1136c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: CIBW_ENVIRONMENT: HNSWLIB_NO_NATIVE=true CIBW_ENVIRONMENT_PASS_LINUX: HNSWLIB_NO_NATIVE CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7" - CIBW_SKIP: "pp* *musllinux* cp312-win*" + CIBW_SKIP: "pp* *musllinux*" CIBW_ARCHS_MACOS: "x86_64 arm64" CIBW_ARCHS_WINDOWS: "AMD64" CIBW_ARCHS_LINUX: "x86_64 aarch64" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9674abb7..8b69605f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -28,7 +28,6 @@ jobs: - name: Test timeout-minutes: 15 run: | - python -m unittest discover -v --start-directory examples/python --pattern "example*.py" python -m unittest discover -v --start-directory tests/python --pattern "bindings_test*.py" test_cpp: @@ -40,7 +39,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" - name: Build run: | @@ -82,4 +81,4 @@ jobs: ./test_updates ./test_updates update ./persistent_test - shell: bash + shell: bash \ No newline at end of file diff --git a/python_bindings/__init__.py b/python_bindings/__init__.py index e69de29b..522e3a99 100644 --- a/python_bindings/__init__.py +++ b/python_bindings/__init__.py @@ -0,0 +1,4 @@ +import faulthandler +from .cpp_bindings import * + +faulthandler.enable() diff --git a/python_bindings/bindings.cpp b/python_bindings/cpp_bindings/bindings.cpp similarity index 99% rename from python_bindings/bindings.cpp rename to python_bindings/cpp_bindings/bindings.cpp index cad2f7b9..ec08f9f6 100644 --- a/python_bindings/bindings.cpp +++ b/python_bindings/cpp_bindings/bindings.cpp @@ -952,9 +952,9 @@ class BFIndex } }; -PYBIND11_PLUGIN(hnswlib) +PYBIND11_PLUGIN(cpp_bindings) { - py::module m("hnswlib"); + py::module m("cpp_bindings"); py::class_>(m, "Index") .def(py::init(&Index::createFromParams), py::arg("params")) diff --git a/python_bindings/setup.py b/python_bindings/setup.py deleted file mode 120000 index f8f80fc2..00000000 --- a/python_bindings/setup.py +++ /dev/null @@ -1 +0,0 @@ -../setup.py \ No newline at end of file diff --git a/setup.py b/setup.py index e9543baa..a8c799b9 100644 --- a/setup.py +++ b/setup.py @@ -13,16 +13,10 @@ include_dirs = [ pybind11.get_include(), np.get_include(), + "./hnswlib", ] -# compatibility when run in python_bindings -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", 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"], )