mirror of https://github.com/astral-sh/uv
Order insertions into the available versions map
This commit is contained in:
parent
0cdde8949f
commit
78004ba66f
|
|
@ -8,8 +8,8 @@ use regex::Regex;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
/// A wrapper around [`Url`] that preserves the original string.
|
/// A wrapper around [`Url`] that preserves the original string.
|
||||||
#[derive(Debug, Clone, Eq, derivative::Derivative)]
|
#[derive(Debug, Clone, Eq, Ord, derivative::Derivative)]
|
||||||
#[derivative(PartialEq, Hash)]
|
#[derivative(PartialEq, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct VerbatimUrl {
|
pub struct VerbatimUrl {
|
||||||
/// The parsed URL.
|
/// The parsed URL.
|
||||||
|
|
@ -22,6 +22,7 @@ pub struct VerbatimUrl {
|
||||||
)]
|
)]
|
||||||
url: Url,
|
url: Url,
|
||||||
/// The URL as it was provided by the user.
|
/// The URL as it was provided by the user.
|
||||||
|
#[derivative(PartialOrd = "ignore")]
|
||||||
#[derivative(PartialEq = "ignore")]
|
#[derivative(PartialEq = "ignore")]
|
||||||
#[derivative(Hash = "ignore")]
|
#[derivative(Hash = "ignore")]
|
||||||
given: Option<String>,
|
given: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use std::convert::Infallible;
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use itertools::Itertools;
|
||||||
use pubgrub::range::Range;
|
use pubgrub::range::Range;
|
||||||
use pubgrub::report::{DefaultStringReporter, DerivationTree, Reporter};
|
use pubgrub::report::{DefaultStringReporter, DerivationTree, Reporter};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
@ -170,18 +171,18 @@ impl NoSolutionError {
|
||||||
package_versions: &OnceMap<PackageName, VersionMap>,
|
package_versions: &OnceMap<PackageName, VersionMap>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut available_versions = IndexMap::default();
|
let mut available_versions = IndexMap::default();
|
||||||
for package in self.derivation_tree.packages() {
|
for package in self.derivation_tree.packages().iter().sorted() {
|
||||||
match package {
|
match package {
|
||||||
PubGrubPackage::Root(_) => {}
|
PubGrubPackage::Root(_) => {}
|
||||||
PubGrubPackage::Python(PubGrubPython::Installed) => {
|
PubGrubPackage::Python(PubGrubPython::Installed) => {
|
||||||
available_versions.insert(
|
available_versions.insert(
|
||||||
package.clone(),
|
(*package).clone(),
|
||||||
BTreeSet::from([python_requirement.installed().clone()]),
|
BTreeSet::from([python_requirement.installed().clone()]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
PubGrubPackage::Python(PubGrubPython::Target) => {
|
PubGrubPackage::Python(PubGrubPython::Target) => {
|
||||||
available_versions.insert(
|
available_versions.insert(
|
||||||
package.clone(),
|
(*package).clone(),
|
||||||
BTreeSet::from([python_requirement.target().clone()]),
|
BTreeSet::from([python_requirement.target().clone()]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +190,7 @@ impl NoSolutionError {
|
||||||
if let Some(entry) = package_versions.get(name) {
|
if let Some(entry) = package_versions.get(name) {
|
||||||
let version_map = entry.value();
|
let version_map = entry.value();
|
||||||
available_versions.insert(
|
available_versions.insert(
|
||||||
package.clone(),
|
(*package).clone(),
|
||||||
version_map
|
version_map
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(version, _)| version.clone())
|
.map(|(version, _)| version.clone())
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use puffin_normalize::{ExtraName, PackageName};
|
||||||
/// 2. Uses the same strategy as pip and posy to handle extras: for each extra, we create a virtual
|
/// 2. Uses the same strategy as pip and posy to handle extras: for each extra, we create a virtual
|
||||||
/// package (e.g., `black[colorama]`), and mark it as a dependency of the real package (e.g.,
|
/// package (e.g., `black[colorama]`), and mark it as a dependency of the real package (e.g.,
|
||||||
/// `black`). We then discard the virtual packages at the end of the resolution process.
|
/// `black`). We then discard the virtual packages at the end of the resolution process.
|
||||||
#[derive(Debug, Clone, Eq, Derivative)]
|
#[derive(Debug, Clone, Eq, Derivative, PartialOrd, Ord)]
|
||||||
#[derivative(PartialEq, Hash)]
|
#[derivative(PartialEq, Hash)]
|
||||||
pub enum PubGrubPackage {
|
pub enum PubGrubPackage {
|
||||||
/// The root package, which is used to start the resolution process.
|
/// The root package, which is used to start the resolution process.
|
||||||
|
|
@ -74,7 +74,7 @@ pub enum PubGrubPackage {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||||
pub enum PubGrubPython {
|
pub enum PubGrubPython {
|
||||||
/// The Python version installed in the current environment.
|
/// The Python version installed in the current environment.
|
||||||
Installed,
|
Installed,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue