From 34ac8cb53fcede26ab252cbcdd1eb8cac949e866 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 13 Aug 2024 12:48:54 -0400 Subject: [PATCH] uv/tests: add an unresolvable test case involving overlapping markers This example came up in discussion and it was initially unclear whether we should try to support it. Specifically, by automatically assuming that the `datasets < 2.19` dependency had a marker corresponding to the negation of the conjunction of the other sibling markers for that same package. But this was deemed, I think, a little too magical. This in turn implies that whenever there are sibling dependencies with overlapping marker expressions, their version constraints also need to be overlapping. Otherwise, for any marker environment that matches both marker expressions, it would be impossible to select a single version. --- crates/uv/tests/lock.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/uv/tests/lock.rs b/crates/uv/tests/lock.rs index e3813bfd73dd..84c41d8cc52e 100644 --- a/crates/uv/tests/lock.rs +++ b/crates/uv/tests/lock.rs @@ -7617,3 +7617,38 @@ fn lock_mismatched_versions() -> Result<()> { Ok(()) } + +/// This checks that overlapping marker expressions with disjoint +/// version constraints fails to resolve. +#[test] +fn unconditional_overlapping_marker_disjoint_version_constraints() -> Result<()> { + let context = TestContext::new("3.12"); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r#" + [project] + name = "project" + version = "0.1.0" + requires-python = ">=3.11" + dependencies = [ + "datasets < 2.19", + "datasets >= 2.19 ; python_version > '3.10'" + ] + "#, + )?; + + uv_snapshot!(context.filters(), context.lock(), @r###" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + warning: `uv lock` is experimental and may change without warning + × No solution found when resolving dependencies for split (python_version > '3.10'): + ╰─▶ Because only datasets{python_version > '3.10'}<2.19 is available and project==0.1.0 depends on datasets{python_version > '3.10'}>=2.19, we can conclude that project==0.1.0 cannot be used. + And because only project==0.1.0 is available and you require project, we can conclude that the requirements are unsatisfiable. + "###); + + Ok(()) +}