Skip to content

🐛 fix(seed): scope pip RECORD rewrites - #3677

Merged
gaborbernat merged 3 commits into
pypa:mainfrom
gaborbernat:fix/7zn-pip-record
Nov 20, 2026
Merged

gaborbernat merged 3 commits into
pypa:mainfrom
gaborbernat:fix/7zn-pip-record

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PipInvoke._rewrite_launchers searched every installed distribution after the pip seeder ran. In a reused environment, stale metadata for a seed package could supply a RECORD path outside that environment. The rewrite now uses the metadata path in each selected wheel. Fixes #3625.

Stale metadata supplied the output path

The seeder invokes pip with --ignore-installed, which overwrites installed packages. The old distribution scan still found stale metadata in the reused destination. It selected the first row ending in .dist-info/RECORD, resolved that row as a path, and wrote there even when the row belonged to another distribution. Before running pip, the new selection takes a top-level RECORD name from each selected wheel; after installation, it reads that file under the environment's site-packages roots. The existing header rewrite and checksum calculation run for rows in that file.

Behavior changes

Reseeding with --seeder pip no longer rewrites stale distributions under other metadata paths or uses their rows to write outside the environment. Launcher rewrites and RECORD updates apply to metadata paths named by the wheels selected for this seed run.

Reported by oss-scanner: ANT-2026-7ZNZMO8Q.

@gaborbernat
gaborbernat force-pushed the fix/7zn-pip-record branch 3 times, most recently from d80d3fa to 094b009 Compare November 20, 2026 09:16
The pip seeder scanned installed metadata after pip ran, including stale
distributions left in a reused environment. A stale RECORD row could direct
the launcher update to another package's RECORD outside the environment.

Read the top-level RECORD name from each selected wheel, then update that
installed metadata file. Nested vendored RECORD files remain outside this
selection.

Fixes pypa#3625
The wheel source can disappear during installation if its cache is reset.
Read the RECORD names while detaching metadata from the wheels, before pip
installs their staged copies.
Validate wheel members before looking up RECORD so invalid entry and script
names still report their specific errors. A wheel without RECORD now raises
a clear error instead of StopIteration.
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 12:16
@gaborbernat
gaborbernat merged commit b491f05 into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/7zn-pip-record branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pip seeder can rewrite a RECORD outside a reused environment

1 participant