Files
uv/crates/uv-resolver/src/dependency_provider.rs
T
konsti ae659c8bfe Stable order for virtual packages (#10024)
uv gives priorities to packages by package name, not by virtual package
(`PubGrubPackage`). pubgrub otoh when prioritizing order the virtual
packages. When the order of virtual packages changes, uv changes its
resolutions and error messages. This means uv was depending on
implementation details of pubgrub's prioritization caching.

This broke with https://github.com/pubgrub-rs/pubgrub/pull/299, which
added a tiebreaker term that made pubgrub's sorting deterministic given
a deterministic ordering of allocating the packages (which happens the
first time pubgrub sees a package).

The new custom tiebreaker decreases the difference to upstream pubgrub.
2024-12-20 09:28:46 +00:00

49 lines
1.2 KiB
Rust

use std::convert::Infallible;
use pubgrub::{Dependencies, DependencyProvider, PackageResolutionStatistics, Range};
use uv_pep440::Version;
use crate::pubgrub::{PubGrubPackage, PubGrubPriority};
use crate::resolver::UnavailableReason;
/// We don't use a dependency provider, we interact with state directly, but we still need this one
/// for type
#[derive(Clone)]
pub(crate) struct UvDependencyProvider;
impl DependencyProvider for UvDependencyProvider {
type P = PubGrubPackage;
type V = Version;
type VS = Range<Version>;
type M = UnavailableReason;
/// Main priority and tiebreak for virtual packages
type Priority = (Option<PubGrubPriority>, u32);
type Err = Infallible;
fn prioritize(
&self,
_package: &Self::P,
_range: &Self::VS,
_stats: &PackageResolutionStatistics,
) -> Self::Priority {
unimplemented!()
}
fn choose_version(
&self,
_package: &Self::P,
_range: &Self::VS,
) -> Result<Option<Self::V>, Self::Err> {
unimplemented!()
}
fn get_dependencies(
&self,
_package: &Self::P,
_version: &Self::V,
) -> Result<Dependencies<Self::P, Self::VS, Self::M>, Self::Err> {
unimplemented!()
}
}