mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-26 09:58:19 +00:00
## Summary This PR avoids: (1) using the lookahead resolver when `--no-deps` is specified (we'll never use those requirements), and (2) including any transitive requirements when searching for allowed URLs, etc., when `--no-deps` is specified. Closes https://github.com/astral-sh/uv/issues/3183.
58 lines
1.9 KiB
Rust
58 lines
1.9 KiB
Rust
use rustc_hash::FxHashSet;
|
|
|
|
use pep508_rs::MarkerEnvironment;
|
|
use uv_normalize::PackageName;
|
|
|
|
use crate::{DependencyMode, Manifest};
|
|
|
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
|
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
|
|
#[cfg_attr(
|
|
feature = "serde",
|
|
serde(deny_unknown_fields, rename_all = "kebab-case")
|
|
)]
|
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
|
pub enum ResolutionMode {
|
|
/// Resolve the highest compatible version of each package.
|
|
#[default]
|
|
Highest,
|
|
/// Resolve the lowest compatible version of each package.
|
|
Lowest,
|
|
/// Resolve the lowest compatible version of any direct dependencies, and the highest
|
|
/// compatible version of any transitive dependencies.
|
|
LowestDirect,
|
|
}
|
|
|
|
/// Like [`ResolutionMode`], but with any additional information required to select a candidate,
|
|
/// like the set of direct dependencies.
|
|
#[derive(Debug, Clone)]
|
|
pub(crate) enum ResolutionStrategy {
|
|
/// Resolve the highest compatible version of each package.
|
|
Highest,
|
|
/// Resolve the lowest compatible version of each package.
|
|
Lowest,
|
|
/// Resolve the lowest compatible version of any direct dependencies, and the highest
|
|
/// compatible version of any transitive dependencies.
|
|
LowestDirect(FxHashSet<PackageName>),
|
|
}
|
|
|
|
impl ResolutionStrategy {
|
|
pub(crate) fn from_mode(
|
|
mode: ResolutionMode,
|
|
manifest: &Manifest,
|
|
markers: &MarkerEnvironment,
|
|
dependencies: DependencyMode,
|
|
) -> Self {
|
|
match mode {
|
|
ResolutionMode::Highest => Self::Highest,
|
|
ResolutionMode::Lowest => Self::Lowest,
|
|
ResolutionMode::LowestDirect => Self::LowestDirect(
|
|
manifest
|
|
.user_requirements(markers, dependencies)
|
|
.map(|requirement| requirement.name.clone())
|
|
.collect(),
|
|
),
|
|
}
|
|
}
|
|
}
|