Skip to content

Commit

Permalink
Use constraints in trace rather than irrelevant requires-python (#9529)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Nov 29, 2024
1 parent 58cf93a commit 9508558
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,15 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
let mut marker = constraint.marker.clone();
marker.and(requirement.marker.clone());

if marker.is_false() {
trace!(
"skipping {constraint} because of disjoint markers: `{}` vs. `{}`",
constraint.marker.try_to_string().unwrap(),
requirement.marker.try_to_string().unwrap(),
);
return None;
}

Cow::Owned(Requirement {
name: constraint.name.clone(),
extras: constraint.extras.clone(),
Expand All @@ -1768,17 +1777,21 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
let mut marker = constraint.marker.clone();
marker.and(requirement.marker.clone());

// Additionally, if the requirement is `requests ; sys_platform == 'darwin'`
// and the constraint is `requests ; python_version == '3.6'`, the
// constraint should only apply when _both_ markers are true.
if marker.is_false() {
trace!("skipping {constraint} because of Requires-Python: {requires_python}");
trace!(
"skipping {constraint} because of disjoint markers: `{}` vs. `{}`",
constraint.marker.try_to_string().unwrap(),
requirement.marker.try_to_string().unwrap(),
);
return None;
}

// Additionally, if the requirement is `requests ; sys_platform == 'darwin'`
// and the constraint is `requests ; python_version == '3.6'`, the
// constraint should only apply when _both_ markers are true.
if python_marker.is_disjoint(&marker) {
trace!(
"skipping constraint {requirement} because of Requires-Python: {requires_python}",
requires_python = python_requirement.target(),
"skipping constraint {requirement} because of Requires-Python: {requires_python}"
);
return None;
}
Expand Down

0 comments on commit 9508558

Please sign in to comment.