fix(python): install the _zvec extension inside the zvec package#511
Open
Cuiyus wants to merge 1 commit into
Open
fix(python): install the _zvec extension inside the zvec package#511Cuiyus wants to merge 1 commit into
Cuiyus wants to merge 1 commit into
Conversation
93d2861 to
46cad84
Compare
The compiled extension `_zvec*.so` (and the DiskANN plugin next to it) was
installed at the site-packages root, polluting the top-level namespace and
importing as the bare top-level module `_zvec`.
Install it into the package directory instead (`zvec/_zvec*.so`) and import it
as `zvec._zvec`. All import sites are updated accordingly:
- 16 `.py` files: `from _zvec[...] import` -> `from zvec._zvec[...] import`
- 2 `.pyi` stubs: `import _zvec.*` and qualified annotations
(`_zvec.typing.DataType`, ...) -> `zvec._zvec.*`
The DiskANN plugin install destination moves to `${...}/zvec` too, so it stays
next to `_zvec.so` and is still found via the `$ORIGIN` rpath at runtime.
pybind11 3.0 names its `def_submodule`s by the actual import path, so
`from zvec._zvec.param import _SearchQuery` resolves correctly (verified).
Verified on macOS arm64: wheel places the extension at
`zvec/_zvec.cpython-311-darwin.so` with nothing at the site-packages root;
full Python test suite passes (1092 passed, 70 skipped).
46cad84 to
c15290b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The compiled extension
_zvec*.sowas installed at the site-packages root (and the DiskANN plugin next to it), polluting the top-level namespace. It was imported everywhere as the bare top-level module_zvec.This moves the extension into the package (
zvec/_zvec*.so) and imports it aszvec._zvec.Changes
CMakeLists.txt: install_zvec(and the DiskANN plugin) into${ZVEC_PY_INSTALL_DIR}/zvecinstead of the platlib root. The plugin stays next to_zvec.so, so the existing$ORIGINrpath (src/binding/python/CMakeLists.txt) still resolves it at runtime..pyfiles:from _zvec[...] import→from zvec._zvec[...] import.pyistubs:import _zvec.*and qualified annotations (_zvec.typing.DataType, …) →zvec._zvec.*pybind11 3.0 names its
def_submodules by the actual import path, sofrom zvec._zvec.param import _SearchQueryresolves correctly — confirmed empirically before the rewrite.Docstrings / error strings that merely mention
_zvecwere intentionally left as prose.Verification (macOS arm64)
zvec/_zvec.cpython-311-darwin.so; nothing left at the site-packages rootimport zvec,import zvec._zvec,from zvec._zvec.param import _SearchQuery, and the public API all import