From ffb69e3f4865e75cf433114a8f1bf1181ae2d32e Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 4 Mar 2024 11:51:19 -0600 Subject: [PATCH] Expose the `--exclude-newer` flag (#2166) Closes https://github.com/astral-sh/uv/issues/2088 --- README.md | 12 ++++++++++++ crates/uv/src/main.rs | 6 +++--- crates/uv/tests/pip_compile.rs | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4ddfc52d..04d51855f 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,18 @@ command line argument. For example, if you're running uv on Python 3.9, but want Python 3.8, you can run `uv pip compile --python-version=3.8 requirements.in` to produce a Python 3.8-compatible resolution. +### Reproducible resolution + +uv supports an `--exclude-newer` option to limit resolution to distributions published before a specific +date, allowing reproduction of installations regardless of new package releases. The date may be specified +as a RFC 3339 timestamp (e.g., `2006-12-02T02:07:43Z`) or UTC date in the same format (e.g., `2006-12-02`). + +Note the package index must support the `upload-time` field as specified in [`PEP 700`](https://peps.python.org/pep-0700/). +If the field is not present for a given distribution, the distribution will be treated as unavailable. + +To ensure reproducibility, messages for unsatisfiable resolutions will not mention that distributions were excluded +due to the `--exclude-newer` flag — newer distributions will be treated as if they do not exist. + ## Platform support uv has Tier 1 support for the following platforms: diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index d31b0f168..85de7817e 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -404,7 +404,7 @@ struct PipCompileArgs { /// /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same /// format (e.g., `2006-12-02`). - #[arg(long, value_parser = date_or_datetime, hide = true)] + #[arg(long, value_parser = date_or_datetime)] exclude_newer: Option>, /// Specify a package to omit from the output resolution. Its dependencies will still be @@ -789,7 +789,7 @@ struct PipInstallArgs { /// /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same /// format (e.g., `2006-12-02`). - #[arg(long, value_parser = date_or_datetime, hide = true)] + #[arg(long, value_parser = date_or_datetime)] exclude_newer: Option>, } @@ -1011,7 +1011,7 @@ struct VenvArgs { /// /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same /// format (e.g., `2006-12-02`). - #[arg(long, value_parser = date_or_datetime, hide = true)] + #[arg(long, value_parser = date_or_datetime)] exclude_newer: Option>, #[command(flatten)] diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index e4e433d14..8feb270d5 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -1613,7 +1613,7 @@ optional-dependencies.bar = [ ----- stderr ----- error: the argument '--all-extras' cannot be used with '--extra ' - Usage: uv pip compile --cache-dir [CACHE_DIR] --all-extras ... + Usage: uv pip compile --cache-dir [CACHE_DIR] --exclude-newer --all-extras ... For more information, try '--help'. "###