Skip to content

Commit

Permalink
Update packse to 0.3.42 for backtracking test
Browse files Browse the repository at this point in the history
Add the missing test for #9843.
  • Loading branch information
konstin committed Dec 18, 2024
1 parent cb325e2 commit c89f63e
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/uv/tests/it/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
162 changes: 161 additions & 1 deletion crates/uv/tests/it/lock_scenarios.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DO NOT EDIT
//!
//! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.39/scenarios>
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.42/scenarios>
//!
#![cfg(all(feature = "python", feature = "pypi"))]
#![allow(clippy::needless_raw_string_hashes)]
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/it/pip_compile_scenarios.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DO NOT EDIT
//!
//! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.39/scenarios>
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.42/scenarios>
//!
#![cfg(all(feature = "python", feature = "pypi", unix))]

Expand Down
18 changes: 14 additions & 4 deletions crates/uv/tests/it/pip_install_scenarios.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DO NOT EDIT
//!
//! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.39/scenarios>
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.42/scenarios>
//!
#![cfg(all(feature = "python", feature = "pypi", unix))]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions scripts/scenarios/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/sync_scenarios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c89f63e

Please sign in to comment.