mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-20 03:49:54 +00:00
Introduce a --fork-strategy preference mode (#9868)
## Summary This PR makes the behavior in https://github.com/astral-sh/uv/pull/9827 the default: we try to select the latest supported package version for each supported Python version, but we still optimize for choosing fewer versions when stratifying by platform. However, you can opt out with `--fork-strategy fewest`. Closes https://github.com/astral-sh/uv/issues/7190.
This commit is contained in:
parent
0ee21146f4
commit
b2459e6326
35 changed files with 699 additions and 48 deletions
23
crates/uv-resolver/src/fork_strategy.rs
Normal file
23
crates/uv-resolver/src/fork_strategy.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
|
||||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum ForkStrategy {
|
||||
/// Optimize for selecting the fewest number of versions for each package. Older versions may
|
||||
/// be preferred if they are compatible with a wider range of supported Python versions or
|
||||
/// platforms.
|
||||
Fewest,
|
||||
/// Optimize for selecting latest supported version of each package, for each supported Python
|
||||
/// version.
|
||||
#[default]
|
||||
RequiresPython,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ForkStrategy {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Fewest => write!(f, "fewest"),
|
||||
Self::RequiresPython => write!(f, "requires-python"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue