mesonbuild / mesonbuild/meson-python

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

Open
#775 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
180
Forks
93
Avg merge
2d 7h
Merged PRs (30d)
18

Description

When a Python package using a [PEP 420](https://peps.python.org/pep-0420) 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`:**

```sh
project-dep/
├── pyproject.toml
└── company_namespace/
└── project_dep/
└── __init__.py
```

- **`project-main`:**

```sh
project-main/
├── pyproject.toml # dependencies: ["project-dep"]
├── meson.build
└── company_namespace/
└── project_main/
├── __init__.py
└── native.c
```

- **Setup:**

```sh
# 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:**

```sh
python
```

```py
>>> import company_namespace.project_main # This works fine
>>> import company_namespace.project_dep # ModuleNotFoundError
Traceback (most recent call last):
File "", line 1, in
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](https://github.com/bastiensoucasse/mesonpy-namespace-editable).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the two example projects' pyproject.toml files and project-main's meson.build, then reproduce the editable install using the listed pip commands. Investigate why importing project-main prevents project-dep from being found in the shared company_namespace; done means both imports work for src and flat layouts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.