Skip to content

namespaced packages ignored/mis-named #16

@H-Plus-Time

Description

@H-Plus-Time

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions