Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PubGrub to 02a19f72d636119fb3f826a922122e21da69cfa5 #370

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 1 addition & 3 deletions crates/install-wheel-rs/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ fn hardlink_wheel_files(
}

// Hardlink the file, unless it's the `RECORD` file, which we modify during installation.
if entry.path().ends_with("RECORD") {
fs::copy(entry.path(), &out_path)?;
} else if use_copy_fallback {
if entry.path().ends_with("RECORD") || use_copy_fallback {
fs::copy(entry.path(), &out_path)?;
} else {
let hard_link_result = fs::hard_link(entry.path(), &out_path);
Expand Down
1 change: 1 addition & 0 deletions crates/puffin-dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod resolve_cli;
mod resolve_many;
mod wheel_metadata;

#[allow(clippy::enum_variant_names)]
#[derive(Parser)]
enum Cli {
/// Build a source distribution into a wheel
Expand Down
9 changes: 4 additions & 5 deletions crates/puffin-resolver/src/pubgrub/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use fxhash::FxHashMap;
use itertools::Itertools;
use pubgrub::range::Range;
use pubgrub::type_aliases::DependencyConstraints;
use tracing::warn;

use pep508_rs::{MarkerEnvironment, Requirement, VersionOrUrl};
Expand All @@ -12,7 +12,7 @@ use crate::pubgrub::{PubGrubPackage, PubGrubVersion};
use crate::ResolveError;

#[derive(Debug)]
pub struct PubGrubDependencies(DependencyConstraints<PubGrubPackage, Range<PubGrubVersion>>);
pub struct PubGrubDependencies(FxHashMap<PubGrubPackage, Range<PubGrubVersion>>);

impl PubGrubDependencies {
/// Generate a set of `PubGrub` dependencies from a set of requirements.
Expand All @@ -23,8 +23,7 @@ impl PubGrubDependencies {
source: Option<&'a PackageName>,
env: &'a MarkerEnvironment,
) -> Result<Self, ResolveError> {
let mut dependencies =
DependencyConstraints::<PubGrubPackage, Range<PubGrubVersion>>::default();
let mut dependencies = FxHashMap::<PubGrubPackage, Range<PubGrubVersion>>::default();

// Iterate over all declared requirements.
for requirement in requirements {
Expand Down Expand Up @@ -138,7 +137,7 @@ impl PubGrubDependencies {
}

/// Convert a [`PubGrubDependencies`] to a [`DependencyConstraints`].
impl From<PubGrubDependencies> for DependencyConstraints<PubGrubPackage, Range<PubGrubVersion>> {
impl From<PubGrubDependencies> for FxHashMap<PubGrubPackage, Range<PubGrubVersion>> {
fn from(dependencies: PubGrubDependencies) -> Self {
dependencies.0
}
Expand Down
12 changes: 8 additions & 4 deletions crates/puffin-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use fxhash::{FxHashMap, FxHashSet};
use pubgrub::error::PubGrubError;
use pubgrub::range::Range;
use pubgrub::solver::{Incompatibility, State};
use pubgrub::type_aliases::DependencyConstraints;
use tokio::select;
use tokio::sync::Mutex;
use tracing::{debug, error, trace};
Expand Down Expand Up @@ -236,7 +235,12 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
));
continue;
}
Dependencies::Known(constraints) if constraints.contains_key(package) => {
Dependencies::Known(constraints)
if constraints
.clone()
.into_iter()
.any(|(dependency, _)| &dependency == package) =>
{
return Err(PubGrubError::SelfDependency {
package: package.clone(),
version: version.clone(),
Expand All @@ -250,7 +254,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
let dep_incompats = state.add_incompatibility_from_dependencies(
package.clone(),
version.clone(),
&dependencies,
dependencies,
);

state.partial_solution.add_version(
Expand Down Expand Up @@ -977,5 +981,5 @@ enum Dependencies {
/// Package dependencies are unavailable.
Unknown,
/// Container for all available package versions.
Known(DependencyConstraints<PubGrubPackage, Range<PubGrubVersion>>),
Known(FxHashMap<PubGrubPackage, Range<PubGrubVersion>>),
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.73"
channel = "nightly"
90 changes: 0 additions & 90 deletions vendor/pubgrub/examples/caching_dependency_provider.rs

This file was deleted.

6 changes: 3 additions & 3 deletions vendor/pubgrub/src/internal/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::internal::partial_solution::{DecisionLevel, PartialSolution};
use crate::internal::small_vec::SmallVec;
use crate::package::Package;
use crate::report::DerivationTree;
use crate::type_aliases::{DependencyConstraints, Map};
use crate::type_aliases::Map;
use crate::version_set::VersionSet;

/// Current state of the PubGrub algorithm.
Expand Down Expand Up @@ -75,12 +75,12 @@ impl<P: Package, VS: VersionSet, Priority: Ord + Clone> State<P, VS, Priority> {
&mut self,
package: P,
version: VS::V,
deps: &DependencyConstraints<P, VS>,
deps: impl IntoIterator<Item = (P, VS)>,
) -> std::ops::Range<IncompId<P, VS>> {
// Create incompatibilities and allocate them in the store.
let new_incompats_id_range = self
.incompatibility_store
.alloc_iter(deps.iter().map(|dep| {
.alloc_iter(deps.into_iter().map(|dep| {
Incompatibility::from_dependency(package.clone(), version.clone(), dep)
}));
// Merge the newly created incompatibilities with the older ones.
Expand Down
6 changes: 3 additions & 3 deletions vendor/pubgrub/src/internal/incompatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
}

/// Build an incompatibility from a given dependency.
pub fn from_dependency(package: P, version: VS::V, dep: (&P, &VS)) -> Self {
pub fn from_dependency(package: P, version: VS::V, dep: (P, VS)) -> Self {
let set1 = VS::singleton(version);
let (p2, set2) = dep;
Self {
package_terms: if set2 == &VS::empty() {
package_terms: if set2 == VS::empty() {
SmallMap::One([(package.clone(), Term::Positive(set1.clone()))])
} else {
SmallMap::Two([
(package.clone(), Term::Positive(set1.clone())),
(p2.clone(), Term::Negative(set2.clone())),
])
},
kind: Kind::FromDependencyOf(package, set1, p2.clone(), set2.clone()),
kind: Kind::FromDependencyOf(package, set1, p2, set2),
}
}

Expand Down
6 changes: 4 additions & 2 deletions vendor/pubgrub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@
//! &self,
//! package: &String,
//! version: &SemanticVersion,
//! ) -> Result<Dependencies<String, SemVS>, Box<dyn Error + Send + Sync>> {
//! unimplemented!()
//! ) -> Result<Dependencies<impl IntoIterator<Item = (String, SemVS)> + Clone>, Box<dyn Error + Send + Sync>>
//! {
//! unimplemented!();
//! Ok(Dependencies::Known([]))
//! }
//! }
//! ```
Expand Down
19 changes: 5 additions & 14 deletions vendor/pubgrub/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<V: Ord> Range<V> {
.segments
.last()
.expect("if there is a first element, there must be a last element");
(bound_as_ref(start), bound_as_ref(&end.1))
(start.as_ref(), end.1.as_ref())
})
}

Expand Down Expand Up @@ -264,15 +264,6 @@ impl<V: Ord> Range<V> {
}
}

/// Implementation of [`Bound::as_ref`] which is currently marked as unstable.
fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
match bound {
Included(v) => Included(v),
Excluded(v) => Excluded(v),
Unbounded => Unbounded,
}
}

fn valid_segment<T: PartialOrd>(start: &Bound<T>, end: &Bound<T>) -> bool {
match (start, end) {
(Included(s), Included(e)) => s <= e,
Expand Down Expand Up @@ -307,7 +298,7 @@ impl<V: Ord + Clone> Range<V> {

(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if i <= e => Excluded(e),
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if e < i => Included(i),
(s, Unbounded) | (Unbounded, s) => bound_as_ref(s),
(s, Unbounded) | (Unbounded, s) => s.as_ref(),
_ => unreachable!(),
}
.cloned();
Expand All @@ -317,7 +308,7 @@ impl<V: Ord + Clone> Range<V> {

(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if i >= e => Excluded(e),
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if e > i => Included(i),
(s, Unbounded) | (Unbounded, s) => bound_as_ref(s),
(s, Unbounded) | (Unbounded, s) => s.as_ref(),
_ => unreachable!(),
}
.cloned();
Expand Down Expand Up @@ -373,7 +364,7 @@ impl<V: Display + Eq> Display for Range<V> {
} else {
for (idx, segment) in self.segments.iter().enumerate() {
if idx > 0 {
write!(f, ", ")?;
write!(f, " | ")?;
}
match segment {
(Unbounded, Unbounded) => write!(f, "*")?,
Expand All @@ -384,7 +375,7 @@ impl<V: Display + Eq> Display for Range<V> {
if v == b {
write!(f, "=={v}")?
} else {
write!(f, ">={v},<={b}")?
write!(f, ">={v}, <={b}")?
}
}
(Included(v), Excluded(b)) => write!(f, ">={v}, <{b}")?,
Expand Down
Loading
Loading