Skip to content

Tell top-level modules from RECORD also on Python 3.10 (#79) - #91

Open
morisil wants to merge 3 commits into
issue-59-stale-dist-infofrom
issue-79-top-level-py310
Open

morisil wants to merge 3 commits into
issue-59-stale-dist-infofrom
issue-79-top-level-py310

Conversation

@morisil

@morisil morisil commented Nov 13, 2026

Copy link
Copy Markdown
Member

Fixes #79

Stacked on #82 (fix of #59) → #70 (fix of #25) — merge #70, then #82, then this one (bottom-up, see CLAUDE.md).

On Python 3.10, importlib.metadata.packages_distributions() reads only top_level.txt,
so an imported distribution built without it (hatchling, flit, … — e.g. idna, typing_extensions) got no name==version constraint and could be upgraded under the running interpreter.

The PLAN script no longer uses packages_distributions() at all — it tells the top-level modules of a distribution of the dependency directory itself, the same way on every Python version:

  • from top_level.txt, or — when it is missing, empty or not UTF-8 — from the raw rows of RECORD;
  • a recorded file counts only with a real module suffix (longest first, so x.cpython-310-x86_64-linux-gnu.so is x), a directory only when its name is an identifier (X.libs/ is no module);
  • a malformed RECORD (blank line, extra column, non-integer size, bad quoting, non-UTF-8) never crashes the plan — Distribution.files raised TypeError for some of these, and packages_distributions() crashed on 3.12+ for several;
  • only distributions in the dependency directory are examined, so no RECORD of the base environment is read.

imported_files (#59) shares the same top-level-name rule (still counting demo.libs/ as files of demo).

Verified with real wheels: 3.10 now constrains idna, typing_extensions, attrs, numpy, google (protobuf); on 3.12–3.14 the selected constraints equal those of the base.

Review

3 rounds:

  1. No blocking findings; polish (empty top_level.txt, malformed RECORD, extension-suffix test) applied.
  2. A blank line or extra column in RECORD crashed the plan with TypeError → RECORD read as raw csv rows; examining only the dependency directory; non-UTF-8 top_level.txt handled.
  3. No blocking findings.

Follow-ups

🤖 Generated with Claude Code

https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG

morisil and others added 3 commits November 11, 2026 23:45
… 3.10 (#79)

packages_distributions of Python 3.10 tells the modules of a distribution
only by top_level.txt, which e.g. hatchling and flit do not write,
so the top-level packages and single-file modules are told by RECORD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
…RD too (#79)

The imported distributions are told by their top-level modules
the same way on every Python, not by packages_distributions,
which tells them only by top_level.txt on Python 3.10,
only of the .py files on 3.11, and fails on a malformed RECORD:
by top_level.txt, otherwise, also when it is empty, by the recorded files,
and none of a malformed RECORD.
imported_files tells the top-level module of a recorded path by the same rule,
with the module suffixes sorted once, the longest first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
…pendency directory (#79)

Distribution.files fails with TypeError on a RECORD with a blank line or an extra column,
and with ValueError on a size which is not a number,
so the top-level modules of a distribution without top_level.txt are told by the csv rows of RECORD,
like imported_files does, and a top_level.txt not in UTF-8 counts as missing.
A directory with a dot in its name, like demo.libs/, is no top-level module of it,
while imported_files still counts its files as of demo.
They are told only of the distributions in the dependency directory,
so that one of the base environment cannot fail the plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant