mesonbuild / mesonbuild/meson-python

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

Offen
#775 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
180
Forks
93
Ø Merge
2 T. 7 Std.
Gemergte PRs (30 T.)
18

Beschreibung

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).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit den pyproject.toml-Dateien der beiden Beispielprojekte und der meson.build von project-main und reproduziere anschließend die Editable-Installation mit den aufgeführten pip-Befehlen. Untersuche, warum das Importieren von project-main verhindert, dass project-dep im gemeinsam genutzten company_namespace gefunden wird; fertig ist es, wenn beide Imports sowohl für src- als auch für Flat-Layouts funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.