mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +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
|
@ -19,7 +19,7 @@ use uv_normalize::{ExtraName, GroupName, PackageName};
|
|||
use uv_pep508::Requirement;
|
||||
use uv_pypi_types::VerbatimParsedUrl;
|
||||
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
|
||||
use uv_resolver::{AnnotationStyle, ExcludeNewer, PrereleaseMode, ResolutionMode};
|
||||
use uv_resolver::{AnnotationStyle, ExcludeNewer, ForkStrategy, PrereleaseMode, ResolutionMode};
|
||||
use uv_static::EnvVars;
|
||||
|
||||
pub mod comma;
|
||||
|
@ -4045,6 +4045,24 @@ pub struct ToolUpgradeArgs {
|
|||
#[arg(long, hide = true)]
|
||||
pub pre: bool,
|
||||
|
||||
/// The strategy to use when selecting multiple versions of a given package across Python
|
||||
/// versions and platforms.
|
||||
///
|
||||
/// By default, uv will optimize for selecting the latest version of each package for each
|
||||
/// supported Python version (`requires-python`), while minimizing the number of selected
|
||||
/// versions across platforms.
|
||||
///
|
||||
/// Under `fewest`, uv will minimize the number of
|
||||
/// selected versions for each package, preferring older versions that are compatible with a
|
||||
/// wider range of supported Python versions or platforms.
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
env = EnvVars::UV_FORK_STRATEGY,
|
||||
help_heading = "Resolver options"
|
||||
)]
|
||||
pub fork_strategy: Option<ForkStrategy>,
|
||||
|
||||
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
|
||||
#[arg(
|
||||
long,
|
||||
|
@ -4834,6 +4852,24 @@ pub struct ResolverArgs {
|
|||
#[arg(long, hide = true, help_heading = "Resolver options")]
|
||||
pub pre: bool,
|
||||
|
||||
/// The strategy to use when selecting multiple versions of a given package across Python
|
||||
/// versions and platforms.
|
||||
///
|
||||
/// By default, uv will optimize for selecting the latest version of each package for each
|
||||
/// supported Python version (`requires-python`), while minimizing the number of selected
|
||||
/// versions across platforms.
|
||||
///
|
||||
/// Under `fewest`, uv will minimize the number of
|
||||
/// selected versions for each package, preferring older versions that are compatible with a
|
||||
/// wider range of supported Python versions or platforms.
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
env = EnvVars::UV_FORK_STRATEGY,
|
||||
help_heading = "Resolver options"
|
||||
)]
|
||||
pub fork_strategy: Option<ForkStrategy>,
|
||||
|
||||
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
|
||||
#[arg(
|
||||
long,
|
||||
|
@ -5006,6 +5042,24 @@ pub struct ResolverInstallerArgs {
|
|||
#[arg(long, hide = true)]
|
||||
pub pre: bool,
|
||||
|
||||
/// The strategy to use when selecting multiple versions of a given package across Python
|
||||
/// versions and platforms.
|
||||
///
|
||||
/// By default, uv will optimize for selecting the latest version of each package for each
|
||||
/// supported Python version (`requires-python`), while minimizing the number of selected
|
||||
/// versions across platforms.
|
||||
///
|
||||
/// Under `fewest`, uv will minimize the number of
|
||||
/// selected versions for each package, preferring older versions that are compatible with a
|
||||
/// wider range of supported Python versions or platforms.
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
env = EnvVars::UV_FORK_STRATEGY,
|
||||
help_heading = "Resolver options"
|
||||
)]
|
||||
pub fork_strategy: Option<ForkStrategy>,
|
||||
|
||||
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
|
||||
#[arg(
|
||||
long,
|
||||
|
|
|
@ -43,6 +43,7 @@ impl From<ResolverArgs> for PipOptions {
|
|||
resolution,
|
||||
prerelease,
|
||||
pre,
|
||||
fork_strategy,
|
||||
config_setting,
|
||||
no_build_isolation,
|
||||
no_build_isolation_package,
|
||||
|
@ -58,6 +59,7 @@ impl From<ResolverArgs> for PipOptions {
|
|||
index_strategy,
|
||||
keyring_provider,
|
||||
resolution,
|
||||
fork_strategy,
|
||||
prerelease: if pre {
|
||||
Some(PrereleaseMode::Allow)
|
||||
} else {
|
||||
|
@ -126,6 +128,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
|
|||
resolution,
|
||||
prerelease,
|
||||
pre,
|
||||
fork_strategy,
|
||||
config_setting,
|
||||
no_build_isolation,
|
||||
no_build_isolation_package,
|
||||
|
@ -150,6 +153,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
|
|||
} else {
|
||||
prerelease
|
||||
},
|
||||
fork_strategy,
|
||||
config_settings: config_setting
|
||||
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
|
||||
no_build_isolation: flag(no_build_isolation, build_isolation),
|
||||
|
@ -235,6 +239,7 @@ pub fn resolver_options(
|
|||
resolution,
|
||||
prerelease,
|
||||
pre,
|
||||
fork_strategy,
|
||||
config_setting,
|
||||
no_build_isolation,
|
||||
no_build_isolation_package,
|
||||
|
@ -291,6 +296,7 @@ pub fn resolver_options(
|
|||
} else {
|
||||
prerelease
|
||||
},
|
||||
fork_strategy,
|
||||
dependency_metadata: None,
|
||||
config_settings: config_setting
|
||||
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
|
||||
|
@ -324,6 +330,7 @@ pub fn resolver_installer_options(
|
|||
resolution,
|
||||
prerelease,
|
||||
pre,
|
||||
fork_strategy,
|
||||
config_setting,
|
||||
no_build_isolation,
|
||||
no_build_isolation_package,
|
||||
|
@ -392,6 +399,7 @@ pub fn resolver_installer_options(
|
|||
} else {
|
||||
prerelease
|
||||
},
|
||||
fork_strategy,
|
||||
dependency_metadata: None,
|
||||
config_settings: config_setting
|
||||
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue