mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Split out SolveState::add_unavailable_version
(#4619)
Reduces the size of the overly complex `solve_tracked` a little. No functional changes.
This commit is contained in:
parent
2b63dfd717
commit
e79fa774b8
1 changed files with 44 additions and 50 deletions
|
@ -451,56 +451,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
||||||
let version = match version {
|
let version = match version {
|
||||||
ResolverVersion::Available(version) => version,
|
ResolverVersion::Available(version) => version,
|
||||||
ResolverVersion::Unavailable(version, reason) => {
|
ResolverVersion::Unavailable(version, reason) => {
|
||||||
// Incompatible requires-python versions are special in that we track
|
state.add_unavailable_version(version, reason)?;
|
||||||
// them as incompatible dependencies instead of marking the package version
|
|
||||||
// as unavailable directly
|
|
||||||
if let UnavailableVersion::IncompatibleDist(
|
|
||||||
IncompatibleDist::Source(IncompatibleSource::RequiresPython(
|
|
||||||
requires_python,
|
|
||||||
kind,
|
|
||||||
))
|
|
||||||
| IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(
|
|
||||||
requires_python,
|
|
||||||
kind,
|
|
||||||
)),
|
|
||||||
) = reason
|
|
||||||
{
|
|
||||||
let python_version: Range<Version> =
|
|
||||||
PubGrubSpecifier::try_from(&requires_python)?.into();
|
|
||||||
|
|
||||||
let package = &state.next;
|
|
||||||
state
|
|
||||||
.pubgrub
|
|
||||||
.add_incompatibility(Incompatibility::from_dependency(
|
|
||||||
package.clone(),
|
|
||||||
Range::singleton(version.clone()),
|
|
||||||
(
|
|
||||||
PubGrubPackage::from(PubGrubPackageInner::Python(
|
|
||||||
match kind {
|
|
||||||
PythonRequirementKind::Installed => {
|
|
||||||
PubGrubPython::Installed
|
|
||||||
}
|
|
||||||
PythonRequirementKind::Target => {
|
|
||||||
PubGrubPython::Target
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
python_version.clone(),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
state
|
|
||||||
.pubgrub
|
|
||||||
.partial_solution
|
|
||||||
.add_decision(state.next.clone(), version);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
state
|
|
||||||
.pubgrub
|
|
||||||
.add_incompatibility(Incompatibility::custom_version(
|
|
||||||
state.next.clone(),
|
|
||||||
version.clone(),
|
|
||||||
UnavailableReason::Version(reason),
|
|
||||||
));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1800,6 +1751,49 @@ impl SolveState {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_unavailable_version(
|
||||||
|
&mut self,
|
||||||
|
version: Version,
|
||||||
|
reason: UnavailableVersion,
|
||||||
|
) -> Result<(), ResolveError> {
|
||||||
|
// Incompatible requires-python versions are special in that we track
|
||||||
|
// them as incompatible dependencies instead of marking the package version
|
||||||
|
// as unavailable directly
|
||||||
|
if let UnavailableVersion::IncompatibleDist(
|
||||||
|
IncompatibleDist::Source(IncompatibleSource::RequiresPython(requires_python, kind))
|
||||||
|
| IncompatibleDist::Wheel(IncompatibleWheel::RequiresPython(requires_python, kind)),
|
||||||
|
) = reason
|
||||||
|
{
|
||||||
|
let python_version: Range<Version> =
|
||||||
|
PubGrubSpecifier::try_from(&requires_python)?.into();
|
||||||
|
|
||||||
|
let package = &self.next;
|
||||||
|
self.pubgrub
|
||||||
|
.add_incompatibility(Incompatibility::from_dependency(
|
||||||
|
package.clone(),
|
||||||
|
Range::singleton(version.clone()),
|
||||||
|
(
|
||||||
|
PubGrubPackage::from(PubGrubPackageInner::Python(match kind {
|
||||||
|
PythonRequirementKind::Installed => PubGrubPython::Installed,
|
||||||
|
PythonRequirementKind::Target => PubGrubPython::Target,
|
||||||
|
})),
|
||||||
|
python_version.clone(),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
self.pubgrub
|
||||||
|
.partial_solution
|
||||||
|
.add_decision(self.next.clone(), version);
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
self.pubgrub
|
||||||
|
.add_incompatibility(Incompatibility::custom_version(
|
||||||
|
self.next.clone(),
|
||||||
|
version.clone(),
|
||||||
|
UnavailableReason::Version(reason),
|
||||||
|
));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn into_resolution(self) -> Resolution {
|
fn into_resolution(self) -> Resolution {
|
||||||
let solution = self.pubgrub.partial_solution.extract_solution();
|
let solution = self.pubgrub.partial_solution.extract_solution();
|
||||||
let mut dependencies: FxHashMap<
|
let mut dependencies: FxHashMap<
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue