Skip to content

Commit

Permalink
Simplify requires-python check in resolver (#9824)
Browse files Browse the repository at this point in the history
## Summary

I believe this is identical.
  • Loading branch information
charliermarsh authored Dec 11, 2024
1 parent 2ca39f1 commit 8110ded
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,43 +1146,31 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
}
CompatibleDist::CompatibleWheel { wheel, .. } => wheel.file.requires_python.as_ref(),
}?;
if python_requirement.installed() == python_requirement.target() {
if !python_requirement
.installed()
.is_contained_by(requires_python)
{
return if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
requires_python.clone(),
PythonRequirementKind::Installed,
)))
} else {
Some(IncompatibleDist::Source(
IncompatibleSource::RequiresPython(
requires_python.clone(),
PythonRequirementKind::Installed,
),
))
};
}
if python_requirement.target().is_contained_by(requires_python) {
None
} else {
if !python_requirement.target().is_contained_by(requires_python) {
return if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
if matches!(dist, CompatibleDist::CompatibleWheel { .. }) {
Some(IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
requires_python.clone(),
if python_requirement.installed() == python_requirement.target() {
PythonRequirementKind::Installed
} else {
PythonRequirementKind::Target
},
)))
} else {
Some(IncompatibleDist::Source(
IncompatibleSource::RequiresPython(
requires_python.clone(),
PythonRequirementKind::Target,
)))
} else {
Some(IncompatibleDist::Source(
IncompatibleSource::RequiresPython(
requires_python.clone(),
PythonRequirementKind::Target,
),
))
};
if python_requirement.installed() == python_requirement.target() {
PythonRequirementKind::Installed
} else {
PythonRequirementKind::Target
},
),
))
}
}
None
}

/// Given a candidate package and version, return its dependencies.
Expand Down

0 comments on commit 8110ded

Please sign in to comment.