Skip to content

Resolve venv base executables independently of cached metadata - #22508

Draft
konsti-openai wants to merge 2 commits into
zb/restore-interpreter-cache-warmingfrom
konsti/venv-cache-recorded-base
Draft

konsti-openai wants to merge 2 commits into
zb/restore-interpreter-cache-warmingfrom
konsti/venv-cache-recorded-base

Conversation

@konsti-openai

@konsti-openai konsti-openai commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Creating a venv from a symlinked Python executable can cache a different base path from the one CPython later reports through sys._base_executable. Cached and freshly queried environments can then disagree, and repairing an executable link can leave child venvs using a stale path.

Remove production reliance on this private attribute. Resolve the base executable when needed from pyvenv.cfg and executable links, using public interpreter metadata to check copied executables. Record uv's choice as uv-base-executable, retain valid aliases, and resolve the base before replacing its source environment. Cache warming remains enabled, and the interpreter cache format is bumped.

Fixes #22383.

Stacked on #22524.

@astral-sh-bot

This comment has been minimized.

Remove sys._base_executable from interpreter discovery and caching. Resolve
base paths from environment configuration, executable links, and public
interpreter metadata when needed, before replacing a source environment.

Keep cache warming and selected aliases, invalidate the old cache format,
and add a regression test for cached discovery through executable symlinks.

Fixes #22383.
@zanieb
zanieb changed the base branch from main to zb/restore-interpreter-cache-warming October 13, 2026 19:01
@zanieb
zanieb force-pushed the konsti/venv-cache-recorded-base branch from 46586ec to 476f403 Compare October 13, 2026 19:01
Self::FlatIndex => "flat-index-v6",
Self::Git => "git-v1",
Self::Interpreter => "interpreter-v4",
Self::Interpreter => "interpreter-v6",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting we're going v4->v6 here 🙂

This branch was previously deployed

1 inactive deployment
automations — 476f403d Deployed Oct 13, 2026 by zanieb via review / security review #50849
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.

Test regression on Gentoo: venv::create_venv_caches_interpreter

4 participants