Fix double self-dependency (#13366)

The fix itself and its documentation live in pubgrub:
https://github.com/astral-sh/pubgrub/pull/44

Fixes #13344

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
konsti 2025-05-13 05:03:44 +02:00 committed by GitHub
parent 3b125dbe71
commit 73d22ac21b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 93 additions and 4 deletions

View file

@ -17403,3 +17403,92 @@ fn compile_broken_active_venv() -> Result<()> {
Ok(())
}
/// <https://github.com/astral-sh/uv/issues/13344>
#[test]
fn pubgrub_panic_double_self_dependency() -> 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",
"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.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
----- stderr -----
Resolved 1 package in [TIME]
");
Ok(())
}
/// <https://github.com/astral-sh/uv/issues/13344>
#[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(())
}