mirror of https://github.com/astral-sh/uv
Layer on our changes
This commit is contained in:
parent
c4e108136d
commit
6bb6923ef4
|
|
@ -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};
|
||||
|
|
@ -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.
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
@ -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(),
|
||||
|
|
@ -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(
|
||||
|
|
@ -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>>),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "1.73"
|
||||
channel = "nightly"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct State<P: Package, VS: VersionSet, Priority: Ord + Clone> {
|
|||
root_package: P,
|
||||
root_version: VS::V,
|
||||
|
||||
incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
|
||||
pub incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
|
||||
|
||||
/// Store the ids of incompatibilities that are already contradicted
|
||||
/// and will stay that way until the next conflict and backtrack is operated.
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ use crate::version_set::VersionSet;
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct Incompatibility<P: Package, VS: VersionSet> {
|
||||
package_terms: SmallMap<P, Term<VS>>,
|
||||
kind: Kind<P, VS>,
|
||||
pub kind: Kind<P, VS>,
|
||||
}
|
||||
|
||||
/// Type alias of unique identifiers for incompatibilities.
|
||||
pub type IncompId<P, VS> = Id<Incompatibility<P, VS>>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Kind<P: Package, VS: VersionSet> {
|
||||
pub enum Kind<P: Package, VS: VersionSet> {
|
||||
/// Initial incompatibility aiming at picking the root package for the first decision.
|
||||
NotRoot(P, VS::V),
|
||||
/// There are no versions in the given range for this package.
|
||||
|
|
|
|||
|
|
@ -252,6 +252,24 @@ impl<P: Package, VS: VersionSet, Priority: Ord + Clone> PartialSolution<P, VS, P
|
|||
}
|
||||
}
|
||||
|
||||
pub fn prioritized_packages(&self) -> impl Iterator<Item = (&P, &VS)> {
|
||||
let check_all = self.changed_this_decision_level
|
||||
== self.current_decision_level.0.saturating_sub(1) as usize;
|
||||
let current_decision_level = self.current_decision_level;
|
||||
self.package_assignments
|
||||
.get_range(self.changed_this_decision_level..)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(move |(_, pa)| {
|
||||
// We only actually need to update the package if its Been changed
|
||||
// since the last time we called prioritize.
|
||||
// Which means it's highest decision level is the current decision level,
|
||||
// or if we backtracked in the mean time.
|
||||
check_all || pa.highest_decision_level == current_decision_level
|
||||
})
|
||||
.filter_map(|(p, pa)| pa.assignments_intersection.potential_package_filter(p))
|
||||
}
|
||||
|
||||
pub fn pick_highest_priority_pkg(
|
||||
&mut self,
|
||||
prioritizer: impl Fn(&P, &VS) -> Priority,
|
||||
|
|
|
|||
|
|
@ -219,8 +219,7 @@
|
|||
//! with a cache, you may want to know that some versions
|
||||
//! do not exist in your cache.
|
||||
|
||||
#![allow(clippy::rc_buffer)]
|
||||
#![warn(missing_docs)]
|
||||
#![allow(clippy::all, unreachable_pub)]
|
||||
|
||||
pub mod error;
|
||||
pub mod package;
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ impl<V: Display + Eq> Display for Range<V> {
|
|||
(Included(v), Unbounded) => write!(f, ">={v}")?,
|
||||
(Included(v), Included(b)) => {
|
||||
if v == b {
|
||||
write!(f, "{v}")?
|
||||
write!(f, "=={v}")?
|
||||
} else {
|
||||
write!(f, ">={v}, <={b}")?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ use std::collections::{BTreeMap, BTreeSet as Set};
|
|||
use std::error::Error;
|
||||
|
||||
use crate::error::PubGrubError;
|
||||
use crate::internal::core::State;
|
||||
use crate::internal::incompatibility::Incompatibility;
|
||||
pub use crate::internal::core::State;
|
||||
pub use crate::internal::incompatibility::{Incompatibility, Kind};
|
||||
use crate::package::Package;
|
||||
use crate::type_aliases::{Map, SelectedDependencies};
|
||||
use crate::version_set::VersionSet;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl<VS: VersionSet> Term<VS> {
|
|||
|
||||
/// Unwrap the set contained in a positive term.
|
||||
/// Will panic if used on a negative set.
|
||||
pub(crate) fn unwrap_positive(&self) -> &VS {
|
||||
pub fn unwrap_positive(&self) -> &VS {
|
||||
match self {
|
||||
Self::Positive(set) => set,
|
||||
_ => panic!("Negative term cannot unwrap positive set"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue