Skip to content
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

namespaced packages ignored/mis-named #16

Open
1 task done
H-Plus-Time opened this issue Dec 20, 2024 · 1 comment
Open
1 task done

namespaced packages ignored/mis-named #16

H-Plus-Time opened this issue Dec 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@H-Plus-Time
Copy link

Bug Description

PEP 420-style namespace packages like the following:

foo_a/
  Cargo.toml
  python/foo/a/
    __init__.py
  pyproject.toml
  src/
    lib.rs
foo_b/
  Cargo.toml
  python/foo/b/
    __init__.py
  pyproject.toml
  src/
    lib.rs

are skipped entirely in find_spec (because they appear as if they are not top-level packages, since importlib.util.find_spec passes a specialized _NamespacePath to find_spec).

Flagging on enable_automatic_installation appears to work, but actually just installs the namespaced package as foo (resulting in silent clobbering of members of the namespace).

I should have a PR soon-ish for this.

Steps to Reproduce

  1. Initialize a boilerplate folder structure along the lines described above, marking python-source = "python", module-name = "foo.._rustin the Cargo.tomls and insertingfrom . import _rust`.
  2. install the hook and import from a venv with the namespace members editable-installed.
  3. Modify any of the files - observe the hook missing them.

Please provide the output of python -m maturin_import_hook version (or provide manually)

OS: Linux-6.12.4-arch1-1-x86_64-with-glibc2.40
Python: CPython 3.12.8
maturin-import-hook: 0.2.0
maturin: maturin 1.7.8
rustc: rustc 1.81.0 (eeb90cda1 2024-09-04)
pip: ?

Does maturin develop work when run manually for your project?

  • Yes/No (leave blank if not applicable)
@H-Plus-Time H-Plus-Time added the bug Something isn't working label Dec 20, 2024
@H-Plus-Time
Copy link
Author

A few repositories where this happens:

Quite possible this is only in mixed python/rust projects, and reproducible in both src-layout and flat-layout packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant