Skip to content

🐛 fix(seed): keep linked seed directories local - #3755

Closed
gaborbernat wants to merge 4 commits into
pypa:mainfrom
gaborbernat:fix/symlink-seed-files
Closed

gaborbernat wants to merge 4 commits into
pypa:mainfrom
gaborbernat:fix/symlink-seed-files

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Reinstalling a seed package with pip in one environment could change the package in every environment sharing its cache (#3620). Environments created with --symlink-app-data now own their package directories and installation metadata. Package files still link to the cache. When pip reinstalls a wheel, it replaces each link with a file in that environment.

Existing environments keep their directory links. Rerun virtualenv on those environments to adopt file links. The same cache images can be reused.

Creating one link per file costs more than linking the whole directory. On Linux with CPython 3.15 and embedded pip, median warm-cache environment creation over 15 runs took 15 ms with file links, 3.6 ms with directory links, and 18 ms with the default copy mode. On Windows 11 with CPython 3.14, median warm-cache creation over nine runs took 422 ms with file links and 471 ms with copies.

Fixes #3620

When environments link a package directory, a pip reinstall replaces files
in their shared cache. Give each environment its own directories and
metadata so pip replaces the local links. Keep the image format usable
by existing environments.

Fixes pypa#3620
Walk the image once and record paths relative to its root while creating
file links. Skip empty directories so a second install can reuse the
environment, even when the wheel contains directory entries.

Refs pypa#3620
A full disk or interrupted install can leave the package directories and
file links in place before RECORD is written. On retry, reuse real
directories and links to the expected image files. Preserve files the
user added to the environment.

Refs pypa#3620
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 install can change other environments' shared seed image

1 participant