Repository navigation
Conversation
Merging this PR will not alter performance
|
ef323b6 to
7be2dba
Compare
7be2dba to
ef934f2
Compare
| Err(uv_python::Error::Query(err)) | ||
| if matches!(root.join("pyvenv.cfg").try_exists(), Ok(false)) => | ||
| { |
There was a problem hiding this comment.
[P2] Preserve unrelated interpreter query errors
A missing pyvenv.cfg is normal for system environments supported through UV_PROJECT_ENVIRONMENT. If such an interpreter loses execute permission, this arm now converts PermissionDenied into Ok(None) on Unix too. Environment initialization then selects another interpreter and reports that the directory cannot be recreated, hiding the actionable permission error. Query also includes cache I/O failures unrelated to virtualenv configuration. Restrict this fallback to the Windows launcher failure being handled and propagate unrelated errors.
| context | ||
| .venv() | ||
| .arg("--clear") | ||
| .arg("--python") | ||
| .arg("3.13") | ||
| .assert() | ||
| .success(); |
There was a problem hiding this comment.
[P3] Recreate the venv without refreshing the cache under test
context.venv() shares the cache used by context.run(), and the venv command already calls cache_virtualenv, which writes current metadata or evicts the entry for an upgradeable interpreter. Consequently, this recreation removes the stale Windows metadata that the test intends to exercise. Resetting the launcher mtime afterward can additionally invalidate the freshly seeded entry through the existing timestamp check. Recreate with --no-cache or a separate cache while retaining the matching launcher timestamp, so removing configuration-based invalidation causes this regression test to fail.
f108bb4 to
ecd9cf9
Compare
| let absolute = std::path::absolute(executable)?; | ||
| let canonical = canonicalize_executable(&absolute)?; | ||
| let cache_entry = Self::cache_entry(&absolute, &canonical, cache); | ||
| let cache_entry = Self::cache_entry(&absolute, &canonical, cache)?; |
There was a problem hiding this comment.
[P2] Bypass inferred caching when configuration reads fail
This ? makes configuration-read failures fatal through PythonEnvironment::cache_virtualenv, unlike query_cached, which bypasses caching. For example, a valid Unix venv can still run Python with a directory at bin/pyvenv.cfg alongside its valid root configuration. uv venv --allow-existing retains that directory, creates the environment, then fails here while priming the cache. Trace the key-construction error and skip the inferred cache write, matching the query path. Add coverage through venv creation; the new unreadable-configuration test only exercises Interpreter::query.
3974966 to
7c993db
Compare
7c993db to
3f25c96
Compare
| let cached = PythonEnvironment::from_root(context.venv.path(), &cache)?; | ||
| let queried = PythonEnvironment::from_root(context.venv.path(), &fresh_cache)?; |
There was a problem hiding this comment.
[P3] Populate the recreated environment’s cache before comparing metadata
The preceding venv --allow-existing --relocatable changes pyvenv.cfg, producing a new cache key. In this head, create_venv constructs an in-memory interpreter without seeding that entry. Consequently, both cached and queried execute Python, so the field-by-field assertions compare two fresh queries rather than exercising cached metadata. Populate the recreated environment’s entry first and compare a subsequent load against the fresh query, or remove this block from the overlay test.
9b70893 to
755bf9d
Compare
Record the libc path reported by the interpreter probe and refresh when something changes. The cache mechanism added here is generic, so we can't add more paths in the future, possibly without bumping the cache format. Bumps the interpreter cache format to store the new metadata. The stack above needs to be merged as one, so we don't bump multiple times. Related issue [#14268](#14268). Closes astral-sh#1818
Recreating a virtual environment or changing its
pyvenv.cfgcan leave cached interpreter metadata valid even though Python now reports different site packages or a different base interpreter. In particular,uv run --withcan expose system packages afterinclude-system-site-packagesis disabled. Windows virtual environment launchers can also retain the same path and copied modification time across Python-version changes.Include the contents of the applicable
pyvenv.cfgfiles in the interpreter cache key, alongside the executable paths and launcher overrides. Queried and inferred interpreter metadata use the same configuration-sensitive key. Queries bypass the cache when configuration cannot be read, and only publish a result if the executable and configuration remain unchanged while Python runs.Fixes astral-sh#18510. Related to astral-sh#16165 and #1674, and the earlier approaches in astral-sh#18537 and astral-sh#19570.