mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Treat Python version as a lower bound in --universal
(#4597)
## Summary Closes https://github.com/astral-sh/uv/issues/4591.
This commit is contained in:
parent
86e6f76836
commit
9ac1a29c7a
2 changed files with 12 additions and 5 deletions
|
@ -569,8 +569,12 @@ pub struct PipCompileArgs {
|
||||||
pub python_platform: Option<TargetTriple>,
|
pub python_platform: Option<TargetTriple>,
|
||||||
|
|
||||||
/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
|
/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
|
||||||
/// file that is compatible with all operating systems, architectures and supported Python
|
/// file that is compatible with all operating systems, architectures, and Python
|
||||||
/// versions.
|
/// implementations.
|
||||||
|
///
|
||||||
|
/// In universal mode, the current Python version (or user-provided `--python-version`) will be
|
||||||
|
/// treated as a lower bound. For example, `--universal --python-version 3.7` would produce a
|
||||||
|
/// universal resolution for Python 3.7 and later.
|
||||||
#[arg(long, overrides_with("no_universal"))]
|
#[arg(long, overrides_with("no_universal"))]
|
||||||
pub universal: bool,
|
pub universal: bool,
|
||||||
|
|
||||||
|
|
|
@ -74,12 +74,15 @@ impl PythonRequirement {
|
||||||
let version_major_minor_only = Version::new(version.release().iter().take(2));
|
let version_major_minor_only = Version::new(version.release().iter().take(2));
|
||||||
let expr_python_version = MarkerExpression::Version {
|
let expr_python_version = MarkerExpression::Version {
|
||||||
key: MarkerValueVersion::PythonVersion,
|
key: MarkerValueVersion::PythonVersion,
|
||||||
specifier: VersionSpecifier::from_version(Operator::Equal, version_major_minor_only)
|
specifier: VersionSpecifier::from_version(
|
||||||
.unwrap(),
|
Operator::GreaterThanEqual,
|
||||||
|
version_major_minor_only,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
};
|
};
|
||||||
let expr_python_full_version = MarkerExpression::Version {
|
let expr_python_full_version = MarkerExpression::Version {
|
||||||
key: MarkerValueVersion::PythonFullVersion,
|
key: MarkerValueVersion::PythonFullVersion,
|
||||||
specifier: VersionSpecifier::from_version(Operator::Equal, version).unwrap(),
|
specifier: VersionSpecifier::from_version(Operator::GreaterThanEqual, version).unwrap(),
|
||||||
};
|
};
|
||||||
MarkerTree::And(vec![
|
MarkerTree::And(vec![
|
||||||
MarkerTree::Expression(expr_python_version),
|
MarkerTree::Expression(expr_python_version),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue