uv/crates
konsti cabca7bf23
Fix metadata cache instability (#6332)
For a path dep such as the root project, uv can read metadata statically
from `pyproject.toml` or dynamically from the build backend.

Python's `packaging`
[sorts](cc938f984b/src/packaging/specifiers.py (L777))
specifiers before emitting them, so all build backends built on top of
it - such as hatchling - will change the specifier order compared to
pyproject.toml. The core metadata spec does say "If a field is not
marked as Dynamic, then the value of the field in any wheel built from
the sdist MUST match the value in the sdist", but it doesn't specify if
"match" means string equivalent or semantically equivalent, so it's
arguable if that spec conformant. This change means that the specifiers
have a different ordering when coming from the build backend than when
read statically from pyproject.toml.

Previously, we tried to read path dep metadata in order:
* From the (built wheel) cache (`packaging` order)
* From pyproject.toml (verbatim specifier)
* From a fresh build (`packaging` order)

This behaviour is unstable: On the first run, we cache is cold, so we
read the verbatim specifier from `pyproject.toml`, then we build and
store the metadata in the cache. On the second run, we read the
`packaging` sorted specifier from the cache.

Reproducer:

```shell
rm -rf newproj
uv init -q --no-config newproj
cd newproj/
uv add -q "anyio>=4,<5"
cat uv.lock | grep "requires-dist"
uv sync -q
cat uv.lock | grep "requires-dist"
cd ..
```

```
requires-dist = [{ name = "anyio", specifier = ">=4,<5" }]
requires-dist = [{ name = "anyio", specifier = "<5,>=4" }]
```

A project either has static metadata, so we can read from
pyproject.toml, or it doesn't, and we always read from the build through
`packaging`. We can use this to stabilize the behavior by slightly
switching the order.

* From pyproject.toml (verbatim specifier)
* From the (built wheel) cache (`packaging` order)
* From a fresh build (`packaging` order)

Potentially, we still want to sort the specifiers we get anyway, after
all, the is no guarantee that the specifiers from a build backend are
deterministic. But our metadata reading behavior should be independent
of the cache state, hence changing the order in the PR.

Fixes #6316
2024-08-21 17:18:42 +02:00
..
bench allow manylinux compatibility override via _manylinux module. (#6039) 2024-08-21 01:57:42 +00:00
cache-key Use hasher to compute resolution hash (#5495) 2024-07-26 23:24:09 +00:00
distribution-filename Lift requirement that .egg-info filenames must include version (#6179) 2024-08-18 13:04:40 -04:00
distribution-types switch to jiff from chrono (#6205) 2024-08-20 11:31:46 -05:00
install-wheel-rs Add export to copy warning (#6294) 2024-08-21 02:29:01 +00:00
once-map Use FxHash in uv-auth (#6149) 2024-08-16 13:14:51 -04:00
pep440-rs Normalize python_version markers to python_full_version (#6126) 2024-08-15 21:42:15 -04:00
pep508-rs Impl Ord for ADD MarkerTree (#6253) 2024-08-20 19:11:57 +02:00
platform-tags allow manylinux compatibility override via _manylinux module. (#6039) 2024-08-21 01:57:42 +00:00
pypi-types switch to jiff from chrono (#6205) 2024-08-20 11:31:46 -05:00
requirements-txt Normalize python_version markers to python_full_version (#6126) 2024-08-15 21:42:15 -04:00
uv Fix metadata cache instability (#6332) 2024-08-21 17:18:42 +02:00
uv-auth Use FxHash in uv-auth (#6149) 2024-08-16 13:14:51 -04:00
uv-build Remove --legacy-setup-py command-line argument (#4255) 2024-08-20 11:31:46 -05:00
uv-cache Migrate to XDG and Linux strategy for macOS directories (#5806) 2024-08-20 11:31:46 -05:00
uv-cli Remove extraneous backtick in help message (#6307) 2024-08-21 07:53:54 +00:00
uv-client Ignore workspace discovery errors with --no-workspace (#6328) 2024-08-21 14:30:01 +00:00
uv-configuration Remove --legacy-setup-py command-line argument (#4255) 2024-08-20 11:31:46 -05:00
uv-dev Remove --legacy-setup-py command-line argument (#4255) 2024-08-20 11:31:46 -05:00
uv-dispatch Remove --legacy-setup-py command-line argument (#4255) 2024-08-20 11:31:46 -05:00
uv-distribution Fix metadata cache instability (#6332) 2024-08-21 17:18:42 +02:00
uv-extract Enforce extension validity at parse time (#5888) 2024-08-08 21:39:47 -04:00
uv-fs Migrate to XDG and Linux strategy for macOS directories (#5806) 2024-08-20 11:31:46 -05:00
uv-git Allow user to constrain supported lock environments (#6210) 2024-08-20 13:28:04 +00:00
uv-installer Use consistent canonicalization for URLs (#5980) 2024-08-09 21:43:36 -04:00
uv-macros Autogenerate possible values for enums in reference documentation (#5137) 2024-07-17 12:37:33 -04:00
uv-normalize Support dev dependencies in virtual workspace roots (#5709) 2024-08-01 21:04:30 +00:00
uv-options-metadata Autogenerate possible values for enums in reference documentation (#5137) 2024-07-17 12:37:33 -04:00
uv-pubgrub Implement marker trees using algebraic decision diagrams (#5898) 2024-08-09 13:40:02 -04:00
uv-python allow manylinux compatibility override via _manylinux module. (#6039) 2024-08-21 01:57:42 +00:00
uv-requirements Avoid displaying "failed to download" on build failures for local source distributions (#6075) 2024-08-14 17:27:55 -05:00
uv-resolver Invalidate uv.lock when virtual dev-dependencies change (#6291) 2024-08-21 01:25:38 +00:00
uv-scripts Misc. edits to script parsing (#5999) 2024-08-10 22:07:05 -04:00
uv-settings Delete the preview default value of python-preference in the document. (#6301) 2024-08-21 08:38:50 +02:00
uv-shell fix(venv): make relocatable activation scripts support ksh (#5640) 2024-07-31 12:18:11 -04:00
uv-state Migrate to XDG and Linux strategy for macOS directories (#5806) 2024-08-20 11:31:46 -05:00
uv-tool Allow customizing the tool install directory with UV_TOOL_BIN_DIR (#6207) 2024-08-19 15:02:10 +00:00
uv-trampoline Update Rust crate which to v6.0.3 (#6193) 2024-08-19 02:31:05 +00:00
uv-types Support no-build-isolation-package (#5894) 2024-08-08 01:35:56 +00:00
uv-version Bump version to 0.3.0 (#6260) 2024-08-20 12:29:58 -05:00
uv-virtualenv Update URL to distutils configuration files docs (#6004) 2024-08-19 11:48:03 +02:00
uv-warnings Upgrade to Rust 1.80.0 (#5472) 2024-07-27 01:49:47 +00:00
uv-workspace Allow user to constrain supported lock environments (#6210) 2024-08-20 13:28:04 +00:00
README.md Use prettier to format the documentation (#5708) 2024-08-02 08:58:31 -05:00

Crates

bench

Functionality for benchmarking uv.

cache-key

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

distribution-filename

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

distribution-types

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

install-wheel-rs

Install built distributions (wheels) into a virtual environment.]

once-map

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

pep440-rs

Utilities for interacting with Python version numbers and specifiers.

pep508-rs

Utilities for interacting with PEP 508 dependency specifiers.

platform-host

Functionality for detecting the current platform (operating system, architecture, etc.).

platform-tags

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

uv

Command-line interface for the uv package manager.

uv-build

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-package

Types and functionality for working with Python packages, e.g., parsing wheel files.

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.

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.

requirements-txt

Functionality for parsing requirements.txt files.