Skip to content

missing modules when upgrading a namespace package where modules have been rearranged #13591

@saucoide

Description

@saucoide

Description

When upgrading a namespace package where the modules have been moved between
the packages, the moved modules are removed but never readded if they are now in a dependency

Expected behavior

upgrading and installing from scratch should result in the same outcome

pip version

25.0.1

Python version

3.12

OS

macos, linux

How to Reproduce

Say you have 1 namespace package with 2 modules, and decide to split them into
2 separate packages, where lib1 depends on the new lib2:

before:


├──  lib1
│   ├──  megaproject
│   │   ├──  bar.py
│   │   └──  foo.py
│   ├──  pyproject.toml
│   └──  README.md

# lib1's pyproject.toml

[project]
name = "lib1"
version = "0.1.0"

after:

 .
├──  lib1
│   ├──  megaproject
│   │   └──  foo.py
│   ├──  pyproject.toml
│   └──  README.md
├──  lib2
│   ├──  megaproject
│   │   └──  bar.py
│   ├──  pyproject.toml
│   └──  README.md
└── 󰌠 requirements.txt

# lib1's pyproject.toml

[project]
name = "lib1"
version = "0.2.0"
dependencies = [ "lib2" ]

If you install version 0.2.0 on a new venv, you end up with the expected files in site-packages:

  • megaproject/bar.py
  • megaproject/foo.py

but if you are upgrading from an existing 0.1.0, the command will succeed,
it'll say we've uninstalled 0.1.0 and installed 0.2.0 + the dependency, with
no errors, but bar.py will be missing from site-packages

Output

Installing collected packages: lib2, lib1
  Attempting uninstall: lib1
    Found existing installation: lib1 0.1.0
    Uninstalling lib1-0.1.0:
      Successfully uninstalled lib1-0.1.0
Successfully installed lib1-0.2.0 lib2-0.1.0

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: needs triageIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions