From c89f63e336a15e02a5b97332a44856c6040a9c56 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 18 Dec 2024 20:40:28 +0100 Subject: [PATCH] Update packse to 0.3.42 for backtracking test Add the missing test for #9843. --- crates/uv/tests/it/common/mod.rs | 2 +- crates/uv/tests/it/lock_scenarios.rs | 162 +++++++++++++++++++- crates/uv/tests/it/pip_compile_scenarios.rs | 2 +- crates/uv/tests/it/pip_install_scenarios.rs | 18 ++- scripts/scenarios/requirements.txt | 14 +- scripts/sync_scenarios.sh | 2 +- 6 files changed, 185 insertions(+), 15 deletions(-) diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index e6eb6373dd50..7f3d70925450 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -32,7 +32,7 @@ use uv_static::EnvVars; // Exclude any packages uploaded after this date. static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z"; -pub const PACKSE_VERSION: &str = "0.3.39"; +pub const PACKSE_VERSION: &str = "0.3.42"; /// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests /// to prevent dependency confusion attacks against our test suite. diff --git a/crates/uv/tests/it/lock_scenarios.rs b/crates/uv/tests/it/lock_scenarios.rs index c2edb01263cf..2043ff91638c 100644 --- a/crates/uv/tests/it/lock_scenarios.rs +++ b/crates/uv/tests/it/lock_scenarios.rs @@ -1,7 +1,7 @@ //! DO NOT EDIT //! //! Generated with `./scripts/sync_scenarios.sh` -//! Scenarios from +//! Scenarios from //! #![cfg(all(feature = "python", feature = "pypi"))] #![allow(clippy::needless_raw_string_hashes)] @@ -17,6 +17,166 @@ use uv_static::EnvVars; use crate::common::{packse_index_url, uv_snapshot, TestContext}; +/// There are two packages, `a` and `b`. We select `a` with `a==2.0.0` first, and then `b`, but `a==2.0.0` conflicts with all new versions of `b`, so we backtrack through versions of `b`. +/// +/// We need to detect this conflict and prioritize `b` over `a` instead of backtracking down to the too old version of `b==1.0.0` that doesn't depend on `a` anymore. +/// +/// ```text +/// wrong-backtracking-basic +/// ├── environment +/// │ └── python3.8 +/// ├── root +/// │ ├── requires a +/// │ │ ├── satisfied by a-1.0.0 +/// │ │ └── satisfied by a-2.0.0 +/// │ └── requires b +/// │ ├── satisfied by b-1.0.0 +/// │ ├── satisfied by b-2.0.0 +/// │ ├── satisfied by b-2.0.1 +/// │ ├── satisfied by b-2.0.2 +/// │ ├── satisfied by b-2.0.3 +/// │ ├── satisfied by b-2.0.4 +/// │ ├── satisfied by b-2.0.5 +/// │ ├── satisfied by b-2.0.6 +/// │ ├── satisfied by b-2.0.7 +/// │ ├── satisfied by b-2.0.8 +/// │ └── satisfied by b-2.0.9 +/// ├── a +/// │ ├── a-1.0.0 +/// │ └── a-2.0.0 +/// ├── b +/// │ ├── b-1.0.0 +/// │ │ └── requires too-old +/// │ │ └── satisfied by too-old-1.0.0 +/// │ ├── b-2.0.0 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.1 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.2 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.3 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.4 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.5 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.6 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.7 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ ├── b-2.0.8 +/// │ │ └── requires a==1.0.0 +/// │ │ └── satisfied by a-1.0.0 +/// │ └── b-2.0.9 +/// │ └── requires a==1.0.0 +/// │ └── satisfied by a-1.0.0 +/// └── too-old +/// └── too-old-1.0.0 +/// ``` +#[test] +fn wrong_backtracking_basic() -> Result<()> { + let context = TestContext::new("3.8"); + + // In addition to the standard filters, swap out package names for shorter messages + let mut filters = context.filters(); + filters.push((r"wrong-backtracking-basic-", "package-")); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r###" + [project] + name = "project" + version = "0.1.0" + dependencies = [ + '''wrong-backtracking-basic-a''', + '''wrong-backtracking-basic-b''', + ] + requires-python = ">=3.8" + "###, + )?; + + let mut cmd = context.lock(); + cmd.env_remove(EnvVars::UV_EXCLUDE_NEWER); + cmd.arg("--index-url").arg(packse_index_url()); + uv_snapshot!(filters, cmd, @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 3 packages in [TIME] + "### + ); + + let lock = context.read("uv.lock"); + insta::with_settings!({ + filters => filters, + }, { + assert_snapshot!( + lock, @r###" + version = 1 + requires-python = ">=3.8" + + [[package]] + name = "project" + version = "0.1.0" + source = { virtual = "." } + dependencies = [ + { name = "package-a" }, + { name = "package-b" }, + ] + + [package.metadata] + requires-dist = [ + { name = "package-a" }, + { name = "package-b" }, + ] + + [[package]] + name = "package-a" + version = "1.0.0" + source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } + sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/wrong_backtracking_basic_a-1.0.0.tar.gz", hash = "sha256:5251a827291d4e5b7ca11c742df3aa26802cc55442e3f5fc307ff3423b8f9295" } + wheels = [ + { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/wrong_backtracking_basic_a-1.0.0-py3-none-any.whl", hash = "sha256:d9a7ee79b176cd36c9db03e36bc3325856dd4fb061aefc6159eecad6e8776e88" }, + ] + + [[package]] + name = "package-b" + version = "2.0.9" + source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } + dependencies = [ + { name = "package-a" }, + ] + sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/wrong_backtracking_basic_b-2.0.9.tar.gz", hash = "sha256:a4e95f3f0f0d82cc5f19de6c638f70300da1b5101f1ba70d8814c7fe7e949e20" } + wheels = [ + { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/wrong_backtracking_basic_b-2.0.9-py3-none-any.whl", hash = "sha256:bf96af1a69f8c1d1d9c2687cd5d6f023cda56dd77d3f37f3cdd422e2a410541f" }, + ] + "### + ); + }); + + // Assert the idempotence of `uv lock` when resolving from the lockfile (`--locked`). + context + .lock() + .arg("--locked") + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("--index-url") + .arg(packse_index_url()) + .assert() + .success(); + + Ok(()) +} + /// This test ensures that multiple non-conflicting but also /// non-overlapping dependency specifications with the same package name /// are allowed and supported. diff --git a/crates/uv/tests/it/pip_compile_scenarios.rs b/crates/uv/tests/it/pip_compile_scenarios.rs index 1b1a0ca1dc24..722d3f0e001c 100644 --- a/crates/uv/tests/it/pip_compile_scenarios.rs +++ b/crates/uv/tests/it/pip_compile_scenarios.rs @@ -1,7 +1,7 @@ //! DO NOT EDIT //! //! Generated with `./scripts/sync_scenarios.sh` -//! Scenarios from +//! Scenarios from //! #![cfg(all(feature = "python", feature = "pypi", unix))] diff --git a/crates/uv/tests/it/pip_install_scenarios.rs b/crates/uv/tests/it/pip_install_scenarios.rs index 6cfa3fb84d20..2ab7b765cb13 100644 --- a/crates/uv/tests/it/pip_install_scenarios.rs +++ b/crates/uv/tests/it/pip_install_scenarios.rs @@ -1,7 +1,7 @@ //! DO NOT EDIT //! //! Generated with `./scripts/sync_scenarios.sh` -//! Scenarios from +//! Scenarios from //! #![cfg(all(feature = "python", feature = "pypi", unix))] @@ -3021,7 +3021,8 @@ fn package_prereleases_global_boundary() { /// │ └── python3.8 /// ├── root /// │ └── requires a<0.2.0a2 -/// │ └── satisfied by a-0.1.0 +/// │ ├── satisfied by a-0.1.0 +/// │ └── satisfied by a-0.2.0a1 /// └── a /// ├── a-0.1.0 /// ├── a-0.2.0 @@ -3162,7 +3163,8 @@ fn requires_package_prerelease_and_final_any() { /// │ ├── requires a /// │ │ └── satisfied by a-0.1.0 /// │ └── requires b>0.0.0a1 -/// │ └── satisfied by b-0.1.0 +/// │ ├── satisfied by b-0.1.0 +/// │ └── satisfied by b-1.0.0a1 /// ├── a /// │ └── a-0.1.0 /// │ └── requires b>0.1 @@ -3329,7 +3331,15 @@ fn transitive_package_only_prereleases() { /// ├── a /// │ └── a-1.0.0 /// │ └── requires c!=2.0.0a5,!=2.0.0a6,!=2.0.0a7,!=2.0.0b1,<2.0.0b5,>1.0.0 -/// │ └── unsatisfied: no matching version +/// │ ├── satisfied by c-2.0.0a1 +/// │ ├── satisfied by c-2.0.0a2 +/// │ ├── satisfied by c-2.0.0a3 +/// │ ├── satisfied by c-2.0.0a4 +/// │ ├── satisfied by c-2.0.0a8 +/// │ ├── satisfied by c-2.0.0a9 +/// │ ├── satisfied by c-2.0.0b2 +/// │ ├── satisfied by c-2.0.0b3 +/// │ └── satisfied by c-2.0.0b4 /// ├── b /// │ └── b-1.0.0 /// │ └── requires c<=3.0.0,>=1.0.0 diff --git a/scripts/scenarios/requirements.txt b/scripts/scenarios/requirements.txt index e53e4bf9043f..d6c9203d0956 100644 --- a/scripts/scenarios/requirements.txt +++ b/scripts/scenarios/requirements.txt @@ -4,23 +4,23 @@ chevron-blue==0.2.1 # via # -r scripts/scenarios/requirements.in # packse -hatchling==1.24.2 +hatchling==1.27.0 # via packse msgspec==0.18.6 # via packse -packaging==24.0 +packaging==24.2 # via hatchling -packse==0.3.39 +packse==0.3.42 # via -r scripts/scenarios/requirements.in pathspec==0.12.1 # via hatchling pluggy==1.5.0 # via hatchling -pyyaml==6.0.1 +pyyaml==6.0.2 # via packse -setuptools==69.5.1 +setuptools==75.6.0 # via packse -trove-classifiers==2024.4.10 +trove-classifiers==2024.10.21.16 # via hatchling -uv==0.4.29 +uv==0.5.10 # via packse diff --git a/scripts/sync_scenarios.sh b/scripts/sync_scenarios.sh index befbb1a1c4c4..62c323b4b389 100755 --- a/scripts/sync_scenarios.sh +++ b/scripts/sync_scenarios.sh @@ -23,7 +23,7 @@ script_root="$(realpath "$(dirname "$0")")" cd "$script_root/scenarios" echo "Setting up a temporary environment..." -uv venv +uv venv -p 3.12 # shellcheck disable=SC1091 source ".venv/bin/activate"