Skip to content

On Python 3.10, an imported distribution without top_level.txt is not protected by a constraint #79

Open

Description

@morisil

PLAN turns the distributions of imported modules into name==version constraints, mapping modules to distributions with importlib.metadata.packages_distributions().
On Python 3.10 it reads only top_level.txt (3.11+ also derives the top-level names from RECORD), and modern wheels (e.g. built by hatchling or flit) don't ship top_level.txt — so on 3.10 such an imported module gets no constraint, and an upgrade forced by another dependency replaces it while loaded.

Reproduction: Python 3.10, idna 3.x installed into the dependency directory and imported, then a snippet declaring another dependency — the plan has no constraint idna==…; on Python 3.14 it has.

Possible fix: on Python < 3.11, derive the top-level names from RECORD (or files) when top_level.txt is missing.

Pre-existing on main; found during the review of the fix for #6.

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