From 89b24cee2aa7921351d07dbc709e9ad32212227b Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 9 May 2025 18:31:42 +0200 Subject: [PATCH 1/5] Fix double self-dependency The fix itself and its documentation live in pubgrub: https://github.com/astral-sh/pubgrub/pull/44 Fixes #13344 --- Cargo.lock | 4 +-- Cargo.toml | 4 +-- crates/uv/tests/it/pip_compile.rs | 42 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5237d4b58366..562981afb2bf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2820,7 +2820,7 @@ dependencies = [ [[package]] name = "pubgrub" version = "0.3.0" -source = "git+https://github.com/astral-sh/pubgrub?rev=a3b4db3abb1829ce889fb89fa6d157fef529ef7e#a3b4db3abb1829ce889fb89fa6d157fef529ef7e" +source = "git+https://github.com/astral-sh/pubgrub?rev=73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb#73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb" dependencies = [ "indexmap", "log", @@ -5957,7 +5957,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "version-ranges" version = "0.1.1" -source = "git+https://github.com/astral-sh/pubgrub?rev=a3b4db3abb1829ce889fb89fa6d157fef529ef7e#a3b4db3abb1829ce889fb89fa6d157fef529ef7e" +source = "git+https://github.com/astral-sh/pubgrub?rev=73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb#73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb" dependencies = [ "smallvec", ] diff --git a/Cargo.toml b/Cargo.toml index 717c9250e6779..0c25c44a12c39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,7 +134,7 @@ percent-encoding = { version = "2.3.1" } petgraph = { version = "0.8.0" } proc-macro2 = { version = "1.0.86" } procfs = { version = "0.17.0", default-features = false, features = ["flate2"] } -pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "a3b4db3abb1829ce889fb89fa6d157fef529ef7e" } +pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb" } quote = { version = "1.0.37" } rayon = { version = "1.10.0" } reflink-copy = { version = "0.1.19" } @@ -179,7 +179,7 @@ tracing-tree = { version = "0.4.0" } unicode-width = { version = "0.2.0" } unscanny = { version = "0.1.0" } url = { version = "2.5.2", features = ["serde"] } -version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "a3b4db3abb1829ce889fb89fa6d157fef529ef7e" } +version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "73d6ecf5a4e4eb1c754b8c3255c4d31bdc266fdb" } walkdir = { version = "2.5.0" } which = { version = "7.0.0", features = ["regex"] } windows-registry = { version = "0.5.0" } diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 99f0e61e326fc..10e0f438479cd 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -17403,3 +17403,45 @@ fn compile_broken_active_venv() -> Result<()> { Ok(()) } + +/// https://github.com/astral-sh/uv/issues/13344 +#[test] +fn pubgrub_panic_twice_self_dep() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context + .temp_dir + .child("pyproject.toml") + .write_str(indoc! {r#" + [project] + name = "foo" + version = "0.1.0" + dependencies = [ + "foo", + "foo", + ] + + [build-system] + requires = ["hatchling"] + build-backend = "hatchling.build" + "#})?; + + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str(".")?; + + uv_snapshot!(context + .pip_compile() + .arg(requirements_in.path()), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] /home/konsti/.local/share/uv/tests/.tmpieyoMB/temp/requirements.in + . + # via -r requirements.in + + ----- stderr ----- + Resolved 1 package in [TIME] + "); + + Ok(()) +} From 9e63f9a30a4ed11333c8a4d29518148f3c61629e Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 9 May 2025 18:55:27 +0200 Subject: [PATCH 2/5] . --- crates/uv/tests/it/pip_compile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 10e0f438479cd..361c5296e8244 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -17404,11 +17404,11 @@ fn compile_broken_active_venv() -> Result<()> { Ok(()) } -/// https://github.com/astral-sh/uv/issues/13344 +/// #[test] fn pubgrub_panic_twice_self_dep() -> Result<()> { let context = TestContext::new("3.12"); - let requirements_in = context + context .temp_dir .child("pyproject.toml") .write_str(indoc! {r#" From b265b78a169d316746025fa4794b6df9f400c623 Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 9 May 2025 20:36:44 +0200 Subject: [PATCH 3/5] . --- crates/uv/tests/it/pip_compile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 361c5296e8244..320fe2fa0df04 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -17435,7 +17435,7 @@ fn pubgrub_panic_twice_self_dep() -> Result<()> { exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] /home/konsti/.local/share/uv/tests/.tmpieyoMB/temp/requirements.in + # uv pip compile --cache-dir [CACHE_DIR] /home/konsti/.local/share/uv/tests/.tmpKLXdrE/temp/requirements.in . # via -r requirements.in From 757ebb6ea99ec2e39b207d4d875890e244e32ce6 Mon Sep 17 00:00:00 2001 From: konstin Date: Mon, 12 May 2025 12:54:55 +0200 Subject: [PATCH 4/5] Snapshot filters --- crates/uv/tests/it/pip_compile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 320fe2fa0df04..5bab1a1e46af7 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -17428,14 +17428,14 @@ fn pubgrub_panic_twice_self_dep() -> Result<()> { let requirements_in = context.temp_dir.child("requirements.in"); requirements_in.write_str(".")?; - uv_snapshot!(context + uv_snapshot!(context.filters(), context .pip_compile() .arg(requirements_in.path()), @r" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] /home/konsti/.local/share/uv/tests/.tmpKLXdrE/temp/requirements.in + # uv pip compile --cache-dir [CACHE_DIR] [TEMP_DIR]/requirements.in . # via -r requirements.in From 125025fe060866889345d516a8d23caf483ecbe4 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 12 May 2025 22:54:49 -0400 Subject: [PATCH 5/5] Another test --- crates/uv/tests/it/pip_compile.rs | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index 5bab1a1e46af7..71fd472d42377 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -17406,7 +17406,7 @@ fn compile_broken_active_venv() -> Result<()> { /// #[test] -fn pubgrub_panic_twice_self_dep() -> Result<()> { +fn pubgrub_panic_double_self_dependency() -> Result<()> { let context = TestContext::new("3.12"); context .temp_dir @@ -17445,3 +17445,50 @@ fn pubgrub_panic_twice_self_dep() -> Result<()> { Ok(()) } + +/// +#[test] +fn pubgrub_panic_double_self_dependency_extra() -> Result<()> { + let context = TestContext::new("3.12"); + context + .temp_dir + .child("pyproject.toml") + .write_str(indoc! {r#" + [project] + name = "foo" + version = "0.1.0" + dependencies = [ + "foo[test]", + "foo[test]", + ] + + [project.optional-dependencies] + test = ["iniconfig"] + + [build-system] + requires = ["hatchling"] + build-backend = "hatchling.build" + "#})?; + + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str(".")?; + + uv_snapshot!(context.filters(), context + .pip_compile() + .arg(requirements_in.path()), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] [TEMP_DIR]/requirements.in + . + # via -r requirements.in + iniconfig==2.0.0 + # via foo + + ----- stderr ----- + Resolved 2 packages in [TIME] + "); + + Ok(()) +}