uv/crates
Zanie Blue 1c7c174bc8
Include the canonical path in the interpreter query cache key (#14331)
This fixes an obscure cache collision in Python interpreter queries,
which we believe to be the root cause of CI flakes we've been seeing
where a project environment is invalidated and recreated.

This work follows from the logs in [this CI
run](https://github.com/astral-sh/uv/actions/runs/15934322410/job/44950599993?pr=14326)
which captured one of the flakes with tracing enabled. There, we can see
that the project environment is invalidated because the Python
interpreter in the environment has a different version than expected:

```
DEBUG Checking for Python environment at `.venv`
TRACE Cached interpreter info for Python 3.12.9, skipping probing: .venv/bin/python3
DEBUG The interpreter in the project environment has different version (3.12.9) than it was created with (3.9.21)
```

(this message is updated to reflect #14329)

The flow is roughly:

- We create an environment with 3.12.9
- We query the environment, and cache the interpreter version for
`.venv/bin/python`
- We create an environment for 3.9.12, replacing the existing one
- We query the environment, and read the cached information

The Python cache entries are keyed by the absolute path to the
interpreter, and rely on the modification time (ctime, nsec resolution)
of the canonicalized path to determine if the cache entry should be
invalidated. The key is a hex representation of a u64 sea hasher output
— which is very unlikely to collide.

After an audit of the Python query caching logic, we determined that the
most likely cause of a collision in cache entries is that the
modification times of underlying interpreters are identical. This seems
pretty feasible, especially if the file system does not support
nanosecond precision — though it appears that the GitHub runners do
support it.

The fix here is to include the canonicalized path in the cache key,
which ensures we're looking at the modification time of the _same_
underlying interpreter.

This will "invalidate" all existing interpreter cache entries but that's
not a big deal.

This should also have the effect of reducing cache churn for
interpreters in virtual environments. Now, when you change Python
versions, we won't invalidate the previous cache entry so if you change
_back_ to the old version we can re-use our cached information.

It's a bit speculative, since we don't have a deterministic reproduction
in CI, but this is the strongest candidate given the logs and should
increase correctness regardless.

Closes https://github.com/astral-sh/uv/issues/14160
Closes https://github.com/astral-sh/uv/issues/13744
Closes https://github.com/astral-sh/uv/issues/13745

Once it's confirmed the flakes are resolved, we should revert

- https://github.com/astral-sh/uv/pull/14275
- #13817
2025-06-30 15:39:47 +00:00
..
uv Ignore invalid build backend settings when not building (#14372) 2025-06-30 16:32:28 +02:00
uv-auth Fix `Indexes::new` doc (#14293) 2025-06-26 20:40:40 +00:00
uv-bench Remove wheel filename benchmark (#14240) 2025-06-24 11:54:12 -04:00
uv-build Bump version to 0.7.17 (#14347) 2025-06-29 09:58:33 -04:00
uv-build-backend Allow symlinks in the build backend (#14212) 2025-06-25 07:44:22 +00:00
uv-build-frontend Lock the source tree when running setuptools, to protect concurrent builds 2025-06-26 12:28:15 -07:00
uv-cache Reduce number of reference-checks for `uv cache clean` (#13669) 2025-05-26 21:43:24 -04:00
uv-cache-info Avoid allocations for default cache keys (#12063) 2025-03-17 19:59:32 -04:00
uv-cache-key Add `DisplaySafeUrl` newtype to prevent leaking of credentials by default (#13560) 2025-05-27 00:05:30 +02:00
uv-cli Require disambiguated relative paths for `--index` (#14152) 2025-06-25 10:02:06 +02:00
uv-client Respect URL-encoded credentials in redirect location (#14315) 2025-06-27 16:41:14 +02:00
uv-configuration Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
uv-console Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-dev Sync latest Python releases (#14339) 2025-06-28 03:08:53 +00:00
uv-dirs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-dispatch Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
uv-distribution Avoid using path URL for workspace Git dependencies in `requirements.txt` (#14288) 2025-06-26 19:48:12 +00:00
uv-distribution-filename Remove wheel filename-from URL conversion (#14223) 2025-06-23 14:26:14 -04:00
uv-distribution-types Consistently normalize trailing slashes on URLs with no path segments (#14349) 2025-06-29 12:25:10 -05:00
uv-extract Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-fs Bump MSRV and `rust-toolchain` version (#14303) 2025-06-27 10:27:45 -04:00
uv-git Skip GitHub fast path when rate-limited (#13033) 2025-06-24 12:11:41 -07:00
uv-git-types make GitOid strict about parsing exactly 40 hex characters 2025-06-09 23:50:36 +00:00
uv-globfilter Change `GlobDirFilter` fallback to `true` (#13882) 2025-06-06 14:07:34 +02:00
uv-install-wheel Add data locations to logging (#13797) 2025-06-03 09:22:18 -05:00
uv-installer Add `DisplaySafeUrl` newtype to prevent leaking of credentials by default (#13560) 2025-05-27 00:05:30 +02:00
uv-macros Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-metadata only warn if CRC appears to be missing (#12722) 2025-04-07 12:49:05 -05:00
uv-normalize Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-once-map Bump MSRV to 1.84 (#12670) 2025-04-04 11:49:26 -04:00
uv-options-metadata Upgrade minimum Rust version to 1.83 (#9815) 2024-12-11 10:06:19 -06:00
uv-pep440 Warn users on `~=` python version specifier (#14008) 2025-06-27 15:48:41 -05:00
uv-pep508 Drop trailing slashes when converting index URL from URL (#14346) 2025-06-29 09:36:13 -04:00
uv-performance-memory-allocator Update Rust crate mimalloc to v0.1.47 (#14207) 2025-06-23 12:07:09 +02:00
uv-platform-tags Add Pyodide support (#12731) 2025-06-03 12:01:26 -05:00
uv-publish Add an `IntoIterator` for `FormMetadata` (#14351) 2025-06-29 15:07:07 -04:00
uv-pypi-types Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
uv-python Include the canonical path in the interpreter query cache key (#14331) 2025-06-30 15:39:47 +00:00
uv-redacted Avoid using path URL for workspace Git dependencies in `requirements.txt` (#14288) 2025-06-26 19:48:12 +00:00
uv-requirements Support reading dependency-groups from pyproject.tomls with no project (#13742) 2025-06-13 22:16:48 +00:00
uv-requirements-txt Make `DisplaySafeUrlRef` Copy and other minor PR follow-ups (#13683) 2025-05-28 06:36:18 -04:00
uv-resolver Avoid rendering desugared prefix matches in error messages (#14195) 2025-06-27 18:06:19 +00:00
uv-scripts handle an existing shebang in `uv init --script` (#14141) 2025-06-19 14:47:22 -07:00
uv-settings Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
uv-shell Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-small-str Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
uv-state Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-static move the test buckets dir into the canonicalized temp dir 2025-06-26 14:56:20 -07:00
uv-tool Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
uv-torch Add auto-detection for AMD GPUs (#14176) 2025-06-21 15:21:06 +00:00
uv-trampoline Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
uv-trampoline-builder Bump MSRV and `rust-toolchain` version (#14303) 2025-06-27 10:27:45 -04:00
uv-types Add `DisplaySafeUrl` newtype to prevent leaking of credentials by default (#13560) 2025-05-27 00:05:30 +02:00
uv-version Bump version to 0.7.17 (#14347) 2025-06-29 09:58:33 -04:00
uv-virtualenv Add check for using minor version link when creating a venv on Windows (#14252) 2025-06-25 10:12:32 +02:00
uv-warnings Consistently use `Ordering::Relaxed` for standalone atomic use cases (#14190) 2025-06-24 12:30:26 -07:00
uv-workspace Ignore invalid build backend settings when not building (#14372) 2025-06-30 16:32:28 +02:00
README.md Link to Dependency specifiers instead of PEP 508 (#8411) 2024-10-21 14:43:38 -04:00

README.md

Crates

uv-bench

Functionality for benchmarking uv.

uv-cache-key

Generic functionality for caching paths, URLs, and other resources across platforms.

uv-distribution-filename

Parse built distribution (wheel) and source distribution (sdist) filenames to extract structured metadata.

uv-distribution-types

Abstractions for representing built distributions (wheels) and source distributions (sdists), and the sources from which they can be downloaded.

uv-install-wheel-rs

Install built distributions (wheels) into a virtual environment.

uv-once-map

A waitmap-like concurrent hash map for executing tasks exactly once.

uv-pep440-rs

Utilities for interacting with Python version numbers and specifiers.

uv-pep508-rs

Utilities for parsing and evaluating dependency specifiers, previously known as PEP 508.

uv-platform-tags

Functionality for parsing and inferring Python platform tags as per PEP 425.

uv-cli

Command-line interface for the uv package manager.

uv-build-frontend

A PEP 517-compatible build frontend for uv.

uv-cache

Functionality for caching Python packages and associated metadata.

uv-client

Client for interacting with PyPI-compatible HTTP APIs.

uv-dev

Development utilities for uv.

uv-dispatch

A centralized struct for resolving and building source distributions in isolated environments. Implements the traits defined in uv-types.

uv-distribution

Client for interacting with built distributions (wheels) and source distributions (sdists). Capable of fetching metadata, distribution contents, etc.

uv-extract

Utilities for extracting files from archives.

uv-fs

Utilities for interacting with the filesystem.

uv-git

Functionality for interacting with Git repositories.

uv-installer

Functionality for installing Python packages into a virtual environment.

uv-python

Functionality for detecting and leveraging the current Python interpreter.

uv-normalize

Normalize package and extra names as per Python specifications.

uv-requirements

Utilities for reading package requirements from pyproject.toml and requirements.txt files.

uv-resolver

Functionality for resolving Python packages and their dependencies.

uv-shell

Utilities for detecting and manipulating shell environments.

uv-types

Shared traits for uv, to avoid circular dependencies.

uv-pypi-types

General-purpose type definitions for types used in PyPI-compatible APIs.

uv-virtualenv

A venv replacement to create virtual environments in Rust.

uv-warnings

User-facing warnings for uv.

uv-workspace

Workspace abstractions for uv.

uv-requirements-txt

Functionality for parsing requirements.txt files.