Skip to content

pip install -e fails to isolate build environment during metadata generation - namespace collision causes import error. #13627

@f3flight

Description

@f3flight

Description

In the company I work at, I ran into the following issue:
I have a library A, which uses hatchling and an internal versioning plugin for it as build dependencies. This internal plugin C uses the following namespace layout "COMPANY.hatch.version"
I have an app B, which uses other internal libraries which also use "COMPANY. ..." namespace. Package A is not a dependency of app B.

What I have ran into is that the following sequence of commands results in a failure:

  1. create & activate a venv
  2. pip install -e B
  3. pip install -e A ----> this fails with ModuleNotFoundError: No module named 'COMPANY.hatch' and error: metadata-generation-failed`

The following works:

  1. create & activate a venv
  2. pip install -e A
  3. pip install -e B

Using PIP_NO_CLEAN=1 I have verified that /tmp/pip-build-env-xxxx/overlay contains package C and "COMPANY.hatch.version" module is present there. However it seems that metadata generation is not correctly isolated, and the process detects "COMPANY" top-level namespace in the current venv, and proceeds to import from there, and therefore fails to use the same namespace from the overlay.

It's a little troublesome for me to provide all the artifacts for a reproduction but I hope the problem is clear enough and whoever is interested in improving pip can create 3 small packages to imitate this situation.

Expected behavior

pip install -e B does not break consequent pip install -e A

pip version

25.2

Python version

3.12

OS

Linux

How to Reproduce

  1. create a sample hatchling version plugin library, call it C, and make its code have namespace "somename.C.*"
  2. create library A which uses hatchling and "C" as build dependency
  3. create library B which uses "somename.B.*" as namespace
  4. create a new venv and activate it
  5. pip install -e B
  6. pip install -e A ---> will fail due to import error of "somename.C"

Output

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: build logicStuff related to metadata generation / wheel generationC: editableEditable installationstype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions