Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ percent-encoding = { version = "2.3.1" }
petgraph = { version = "0.8.0" }
proc-macro2 = { version = "1.0.86" }
procfs = { version = "0.18.0", default-features = false, features = ["flate2"] }
pubgrub = { version = "0.3.3", package = "astral-pubgrub" }
pubgrub = { version = "0.5.0", package = "astral-pubgrub" }
quote = { version = "1.0.37" }
rand = { version = "0.9.4" }
rayon = { version = "1.10.0" }
Expand Down Expand Up @@ -289,7 +289,7 @@ unicode-width = { version = "0.2.0" }
unscanny = { version = "0.1.0" }
url = { version = "2.5.2", features = ["serde"] }
uuid = { version = "1.16.0" }
version-ranges = { version = "0.1.3", package = "astral-version-ranges" }
version-ranges = { version = "0.2.0", package = "astral-version-ranges" }
walkdir = { version = "2.5.0" }
webpki-root-certs = { version = "1" }
which = { version = "8.0.0", features = ["regex"] }
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-pep440/src/version_specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl VersionSpecifiers {
///
/// This function is not applicable to ranges involving pre-release versions.
pub fn from_release_only_bounds<'a>(
mut bounds: impl Iterator<Item = (&'a Bound<Version>, &'a Bound<Version>)>,
mut bounds: impl Iterator<Item = (Bound<&'a Version>, Bound<&'a Version>)>,
) -> Self {
let mut specifiers = Vec::new();

Expand Down Expand Up @@ -552,7 +552,7 @@ impl VersionSpecifier {
///
/// This function is not applicable to ranges involving pre-release versions.
pub fn from_release_only_bounds(
bounds: (&Bound<Version>, &Bound<Version>),
bounds: (Bound<&Version>, Bound<&Version>),
) -> impl Iterator<Item = Self> {
let (b1, b2) = match bounds {
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
Expand All @@ -572,8 +572,8 @@ impl VersionSpecifier {
(Some(Self::equals_star_version(version)), None)
}
_ => (
Self::from_lower_bound(&Bound::Included(v1.clone())),
Self::from_upper_bound(&Bound::Excluded(v2.clone())),
Self::from_lower_bound(Bound::Included(v1)),
Self::from_upper_bound(Bound::Excluded(v2)),
),
}
}
Expand All @@ -584,7 +584,7 @@ impl VersionSpecifier {
}

/// Returns a version specifier representing the given lower bound.
fn from_lower_bound(bound: &Bound<Version>) -> Option<Self> {
fn from_lower_bound(bound: Bound<&Version>) -> Option<Self> {
match bound {
Bound::Included(version) => {
Some(Self::from_version(Operator::GreaterThanEqual, version.clone()).unwrap())
Expand All @@ -597,7 +597,7 @@ impl VersionSpecifier {
}

/// Returns a version specifier representing the given upper bound.
fn from_upper_bound(bound: &Bound<Version>) -> Option<Self> {
fn from_upper_bound(bound: Bound<&Version>) -> Option<Self> {
match bound {
Bound::Included(version) => {
Some(Self::from_version(Operator::LessThanEqual, version.clone()).unwrap())
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-pep508/src/marker/algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,13 @@ impl Edges {

// Add the `true` edges.
for (start, end) in range.iter() {
let range = Ranges::from_range_bounds((start.clone(), end.clone()));
let range = Ranges::from_range_bounds((start.cloned(), end.cloned()));
edges.push((range, NodeId::TRUE));
}

// Add the `false` edges.
for (start, end) in range.complement().iter() {
let range = Ranges::from_range_bounds((start.clone(), end.clone()));
let range = Ranges::from_range_bounds((start.cloned(), end.cloned()));
edges.push((range, NodeId::FALSE));
}

Expand Down
6 changes: 3 additions & 3 deletions crates/uv-pep508/src/marker/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl MarkerOperator {

/// Returns the marker operator and value whose union represents the given range.
pub(crate) fn from_bounds(
bounds: (&Bound<ArcStr>, &Bound<ArcStr>),
bounds: (Bound<&ArcStr>, Bound<&ArcStr>),
) -> impl Iterator<Item = (Self, ArcStr)> {
let (b1, b2) = match bounds {
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
Expand All @@ -321,7 +321,7 @@ impl MarkerOperator {
}

/// Returns a value specifier representing the given lower bound.
fn from_lower_bound(bound: &Bound<ArcStr>) -> Option<(Self, ArcStr)> {
fn from_lower_bound(bound: Bound<&ArcStr>) -> Option<(Self, ArcStr)> {
match bound {
Bound::Included(value) => Some((Self::GreaterEqual, value.clone())),
Bound::Excluded(value) => Some((Self::GreaterThan, value.clone())),
Expand All @@ -330,7 +330,7 @@ impl MarkerOperator {
}

/// Returns a value specifier representing the given upper bound.
fn from_upper_bound(bound: &Bound<ArcStr>) -> Option<(Self, ArcStr)> {
fn from_upper_bound(bound: Bound<&ArcStr>) -> Option<(Self, ArcStr)> {
match bound {
Bound::Included(value) => Some((Self::LessEqual, value.clone())),
Bound::Excluded(value) => Some((Self::LessThan, value.clone())),
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ impl SentinelRange<'_> {
pub fn strip(&self) -> Ranges<Version> {
self.0
.iter()
.map(|(lower, upper)| Self::strip_sentinel(lower.clone(), upper.clone()))
.map(|(lower, upper)| Self::strip_sentinel(lower.cloned(), upper.cloned()))
.collect()
}

Expand Down Expand Up @@ -1406,7 +1406,7 @@ impl<'a> PrefixMatch<'a> {
///
/// Prefix matches are desugared to (e.g.) `>=2.4.dev0,<2.5.dev0`, but we want to render them
/// as `==2.4.*` in error messages.
pub(crate) fn from_range(lower: &'a Bound<Version>, upper: &'a Bound<Version>) -> Option<Self> {
pub(crate) fn from_range(lower: Bound<&'a Version>, upper: Bound<&'a Version>) -> Option<Self> {
let Bound::Included(lower) = lower else {
return None;
};
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ fn update_availability_range(
range
.iter()
.filter_map(|(lower, upper)| {
let segment_range = Range::from_range_bounds((lower.clone(), upper.clone()));
let segment_range = Range::from_range_bounds((lower.cloned(), upper.cloned()));

// Drop the segment if it's disjoint with the available range, e.g., if the segment is
// `foo>999`, and the available versions are all `<10` it's useless to show.
Expand Down Expand Up @@ -2412,13 +2412,13 @@ fn update_availability_range(
Bound::Included(version) if !version_contained_in(version, available_versions) => {
Bound::Excluded(version.clone())
}
_ => (*lower).clone(),
_ => lower.cloned(),
};
let upper = match upper {
Bound::Included(version) if !version_contained_in(version, available_versions) => {
Bound::Excluded(version.clone())
}
_ => (*upper).clone(),
_ => upper.cloned(),
};

Some((lower, upper))
Expand Down Expand Up @@ -2477,7 +2477,7 @@ impl std::fmt::Display for PackageRange<'_> {
}
}
(Bound::Included(v), Bound::Excluded(b)) => {
if let Some(prefix) = PrefixMatch::from_range(lower, upper) {
if let Some(prefix) = PrefixMatch::from_range(*lower, *upper) {
write!(f, "{package}{prefix}")?;
} else {
write!(f, "{package}>={v},<{b}")?;
Expand Down
13 changes: 9 additions & 4 deletions crates/uv-resolver/src/resolver/derivation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pubgrub::{Id, Kind, State};
use pubgrub::{Id, Kind, Ranges, State};
use rustc_hash::FxHashMap;

use uv_distribution_types::{DerivationChain, DerivationStep};
Expand Down Expand Up @@ -37,8 +37,13 @@ impl DerivationChainBuilder {
let incompat = &state.incompatibility_store[*index];

// Find a dependency from a package to the current package.
if let Kind::FromDependencyOf(id1, _, id2, v2) = &incompat.kind {
if id == *id2 && v2.contains(version) {
if let Kind::FromDependencyOf(id1, id2) = &incompat.kind {
let Some((_, dependency_versions)) = incompat.dependency_version_sets() else {
continue;
};
let dependency_versions =
dependency_versions.cloned().unwrap_or_else(Ranges::empty);
if id == *id2 && dependency_versions.contains(version) {
if let Some(version) = solution.get(id1) {
let p1 = &state.package_store[*id1];
let p2 = &state.package_store[*id2];
Expand All @@ -55,7 +60,7 @@ impl DerivationChainBuilder {
p1.extra().cloned(),
p1.group().cloned(),
Some(version.clone()),
v2.clone(),
dependency_versions,
));

// Recursively search the next package.
Expand Down
30 changes: 19 additions & 11 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
if dist.wheel().is_none() {
if !self.selector.use_highest_version(&package_name, &env) {
if let Some((lower, _)) = range.iter().next() {
if lower == &Bound::Unbounded {
if lower == Bound::Unbounded {
debug!(
"Skipping prefetch for unbounded minimum-version range: {package_name} ({range})"
);
Expand Down Expand Up @@ -3160,8 +3160,11 @@ impl ForkState {

let proxy_package = self.pubgrub.package_store.alloc(package.clone());
let base_package_id = self.pubgrub.package_store.alloc(base_package.clone());
self.pubgrub
.add_proxy_package(proxy_package, base_package_id, version.clone());
self.pubgrub.add_proxy_package_incompatibility(
proxy_package,
base_package_id,
version.clone(),
);
}

let conflict = self.pubgrub.add_package_version_dependencies(
Expand Down Expand Up @@ -3323,15 +3326,20 @@ impl ForkState {
let mut edges: Vec<ResolutionDependencyEdge> = Vec::with_capacity(edge_count);
for (package, self_version) in &solution {
for id in &self.pubgrub.incompatibilities[package] {
let pubgrub::Kind::FromDependencyOf(
self_package,
ref self_range,
dependency_package,
ref dependency_range,
) = self.pubgrub.incompatibility_store[*id].kind
let incompatibility = &self.pubgrub.incompatibility_store[*id];
let pubgrub::Kind::FromDependencyOf(self_package, dependency_package) =
&incompatibility.kind
else {
continue;
};
let (self_package, dependency_package) = (*self_package, *dependency_package);
let Some((self_range, dependency_range)) =
incompatibility.dependency_version_sets()
else {
continue;
};
let dependency_range =
dependency_range.map_or_else(|| Cow::Owned(Ranges::empty()), Cow::Borrowed);
if *package != self_package {
continue;
}
Expand Down Expand Up @@ -4257,7 +4265,7 @@ fn find_environments(id: Id<PubGrubPackage>, state: &State<UvDependencyProvider>

for index in incompatibilities {
let incompat = &state.incompatibility_store[*index];
if let Kind::FromDependencyOf(parent, _, child, _) = &incompat.kind {
if let Kind::FromDependencyOf(parent, child) = &incompat.kind {
if current != *child {
continue;
}
Expand Down Expand Up @@ -4291,7 +4299,7 @@ fn find_environments(id: Id<PubGrubPackage>, state: &State<UvDependencyProvider>

for index in incompatibilities {
let incompat = &state.incompatibility_store[*index];
let Kind::FromDependencyOf(parent, _, child, _) = &incompat.kind else {
let Kind::FromDependencyOf(parent, child) = &incompat.kind else {
continue;
};
if current != *parent || !ancestors.contains(child) {
Expand Down
Loading