Skip to content

Editable install of a PEP 420 namespace package shadows other packages in the same namespace #775

Open
@bastiensoucasse

Description

@bastiensoucasse

When a Python package using a PEP 420 implicit namespace is installed in editable mode, it shadows/hides other packages installed in the same namespace. This makes the other packages in the shared namespace un-importable, leading to ModuleNotFoundError.

Note: It's the same for both src and flat layouts.

Steps to reproduce:

Here is a minimal example with two packages, project-dep and project-main, which both live in the company_namespace implicit namespace. project-main depends on project-dep.

  • project-dep:
project-dep/
├── pyproject.toml
└── company_namespace/
    └── project_dep/
        └── __init__.py
  • project-main:
project-main/
├── pyproject.toml  # dependencies: ["project-dep"]
├── meson.build
└── company_namespace/
    └── project_main/
        ├── __init__.py
        └── native.c
  • Setup:
# Install build requirements
pip install meson-python

# Install project-dep
pip install ./project-dep

# Install project-main as editable
pip install --no-build-isolation -e ./project-main
  • Test:
python
>>> import company_namespace.project_main  # This works fine
>>> import company_namespace.project_dep  # ModuleNotFoundError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import platform
ModuleNotFoundError: No module named 'company_namespace.project_dep'

Example

A ready-to-use example is set up here: https://github.com/bastiensoucasse/mesonpy-namespace-editable.

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