Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Key cached environments by the base interpreter path and version
  • Loading branch information
charliermarsh committed Oct 30, 2026
commit 19e5098451381bcba9032c523abe6c03d306e976
19 changes: 6 additions & 13 deletions crates/uv-environment-operations/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,18 @@ impl CachedEnvironment {

// Construct a hash for the environment.
//
// Use the canonicalized base interpreter path since that's the interpreter we performed the
// resolution with and the interpreter the environment will be created with.
// Include the base interpreter's version alongside its canonical path so that upgrading
// the interpreter in place creates a new environment.
//
// We cache environments independent of the environment they'd be layered on top of. The
// assumption is such that the environment will _not_ be modified by the user or uv;
// otherwise, we risk cache poisoning. For example, if we were to write a `.pth` file to
// the cached environment, it would be shared across all projects that use the same
// interpreter and the same cached dependencies.
//
// Include the local version to invalidate environments whose entry points contain the
// absolute path to the temporary environment they were installed in.
let executable = canonicalize_executable(interpreter.sys_executable())?;
let version = interpreter.python_version();
let interpreter_hash = if version.is_local() {
cache_digest(&(executable, version))
} else {
// TODO(zanieb): Include the base interpreter version when it changes at the same path.
cache_digest(&executable)
};
let interpreter_hash = cache_digest(&(
canonicalize_executable(interpreter.sys_executable())?,
interpreter.python_version(),
));

// Search in the content-addressed cache.
let cache_entry = cache.entry(CacheBucket::Environments, interpreter_hash, resolution_hash);
Expand Down
Loading
⌂ 换网址