diff --git a/Cargo.lock b/Cargo.lock index b03506e7af9d..16aa771e3c4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2246,7 +2246,7 @@ dependencies = [ [[package]] name = "pubgrub" version = "0.2.1" -source = "git+https://github.com/zanieb/pubgrub?rev=78b8add6942766e5fb070bbda1de570e93d6399f#78b8add6942766e5fb070bbda1de570e93d6399f" +source = "git+https://github.com/zanieb/pubgrub?rev=866c0f2a87fee1e8abe804d40a2ee934de0973d7#866c0f2a87fee1e8abe804d40a2ee934de0973d7" dependencies = [ "indexmap 2.1.0", "log", diff --git a/Cargo.toml b/Cargo.toml index 50dc9a324b0b..9228fca7907c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ owo-colors = { version = "3.5.0" } petgraph = { version = "0.6.4" } platform-info = { version = "2.0.2" } plist = { version = "1.6.0" } -pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "78b8add6942766e5fb070bbda1de570e93d6399f" } +pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "866c0f2a87fee1e8abe804d40a2ee934de0973d7" } pyo3 = { version = "0.20.2" } pyo3-log = { version = "0.9.0"} pyproject-toml = { version = "0.8.1" } diff --git a/crates/puffin-cli/tests/pip_install_scenarios.rs b/crates/puffin-cli/tests/pip_install_scenarios.rs index 8370df073459..b98d3c881439 100644 --- a/crates/puffin-cli/tests/pip_install_scenarios.rs +++ b/crates/puffin-cli/tests/pip_install_scenarios.rs @@ -262,7 +262,7 @@ fn dependency_excludes_range_of_compatible_versions() -> Result<()> { Because there is no version of c available matching <1.0.0 | >1.0.0, <2.0.0 | >2.0.0 and c==1.0.0 depends on a<2.0.0, c<2.0.0 depends on a<2.0.0. And because c==2.0.0 depends on a>=3.0.0, c depends on a<2.0.0 | >=3.0.0. - And because a<2.0.0 depends on b==1.0.0 (1), a Not ( ==3.0.0 ), c *, b Not ( ==1.0.0 ) are incompatible. + And because a<2.0.0 depends on b==1.0.0 (1), a!=3.0.0, c*, b!=1.0.0 are incompatible. And because a==3.0.0 depends on b==3.0.0, c depends on b<=1.0.0 | >=3.0.0. And because root depends on c and root depends on b>=2.0.0, <3.0.0, version solving failed. "###); @@ -1466,7 +1466,7 @@ fn requires_transitive_prerelease_and_stable_dependency_many_versions() -> Resul × No solution found when resolving dependencies: ╰─▶ Because there is no version of b available matching <1.0.0 | >1.0.0 and b==1.0.0 depends on c, b depends on c. And because there is no version of c available matching >=2.0.0b1, b depends on c<2.0.0b1. - And because a==1.0.0 depends on c>=2.0.0b1 and there is no version of a available matching <1.0.0 | >1.0.0, b *, a * are incompatible. + And because a==1.0.0 depends on c>=2.0.0b1 and there is no version of a available matching <1.0.0 | >1.0.0, b*, a* are incompatible. And because root depends on b and root depends on a, version solving failed. hint: c was requested with a pre-release marker (e.g., >=2.0.0b1), but pre-releases weren't enabled (try: `--prerelease=allow`) @@ -2051,7 +2051,7 @@ fn requires_transitive_incompatible_with_transitive() -> Result<()> { ----- stderr ----- × No solution found when resolving dependencies: ╰─▶ Because there is no version of b available matching <1.0.0 | >1.0.0 and b==1.0.0 depends on c==2.0.0, b depends on c==2.0.0. - And because a==1.0.0 depends on c==1.0.0 and there is no version of a available matching <1.0.0 | >1.0.0, a *, b * are incompatible. + And because a==1.0.0 depends on c==1.0.0 and there is no version of a available matching <1.0.0 | >1.0.0, a*, b* are incompatible. And because root depends on b and root depends on a, version solving failed. "###); }); @@ -2447,11 +2447,11 @@ fn requires_python_version_greater_than_current_excluded() -> Result<()> { ----- stderr ----- × No solution found when resolving dependencies: - ╰─▶ Because there is no version of Python available matching >=3.10, <3.11 and there is no version of Python available matching >=3.12, Python >=3.10, <3.11 | >=3.12 are incompatible. - And because there is no version of Python available matching >=3.11, <3.12, Python >=3.10 are incompatible. + ╰─▶ Because there is no version of Python available matching >=3.10, <3.11 and there is no version of Python available matching >=3.12, Python>=3.10, <3.11 | >=3.12 are incompatible. + And because there is no version of Python available matching >=3.11, <3.12, Python>=3.10 are incompatible. And because a==2.0.0 depends on Python>=3.10 and there is no version of a available matching >2.0.0, <3.0.0 | >3.0.0, <4.0.0 | >4.0.0, a>=2.0.0, <3.0.0 is forbidden. (1) - Because there is no version of Python available matching >=3.11, <3.12 and there is no version of Python available matching >=3.12, Python >=3.11 are incompatible. + Because there is no version of Python available matching >=3.11, <3.12 and there is no version of Python available matching >=3.12, Python>=3.11 are incompatible. And because a==3.0.0 depends on Python>=3.11, a==3.0.0 is forbidden. And because a>=2.0.0, <3.0.0 is forbidden (1), a>=2.0.0, <4.0.0 is forbidden. (2) diff --git a/crates/puffin-resolver/src/pubgrub/report.rs b/crates/puffin-resolver/src/pubgrub/report.rs index 237a39c6ce97..53097d54823a 100644 --- a/crates/puffin-resolver/src/pubgrub/report.rs +++ b/crates/puffin-resolver/src/pubgrub/report.rs @@ -125,7 +125,10 @@ impl ReportFormatter> for PubGrubReportFor &External::FromDependencyOf((*p2).clone(), r2.clone(), (*p1).clone(), r1.clone()), ), slice => { - let str_terms: Vec<_> = slice.iter().map(|(p, t)| format!("{p} {t}")).collect(); + let str_terms: Vec<_> = slice + .iter() + .map(|(p, t)| format!("{p}{}", PubGrubTerm::from_term((*t).clone()))) + .collect(); str_terms.join(", ") + " are incompatible" } } @@ -232,3 +235,29 @@ impl std::fmt::Display for PubGrubHint { } } } + +/// A derivative of the [Term] type with custom formatting. +struct PubGrubTerm { + inner: Term>, +} + +impl std::fmt::Display for PubGrubTerm { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match &self.inner { + Term::Positive(set) => write!(f, "{set}"), + Term::Negative(set) => { + if let Some(version) = set.as_singleton() { + write!(f, "!={version}") + } else { + write!(f, "!( {set} )") + } + } + } + } +} + +impl PubGrubTerm { + fn from_term(term: Term>) -> PubGrubTerm { + PubGrubTerm { inner: term } + } +}