Skip to content

Commit

Permalink
Treat Python version as a lower bound in --universal (#4597)
Browse files Browse the repository at this point in the history
## Summary

Closes #4591.
  • Loading branch information
charliermarsh committed Jun 27, 2024
1 parent 86e6f76 commit 9ac1a29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,12 @@ pub struct PipCompileArgs {
pub python_platform: Option<TargetTriple>,

/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
/// file that is compatible with all operating systems, architectures and supported Python
/// versions.
/// file that is compatible with all operating systems, architectures, and Python
/// 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"))]
pub universal: bool,

Expand Down
9 changes: 6 additions & 3 deletions crates/uv-resolver/src/python_requirement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ impl PythonRequirement {
let version_major_minor_only = Version::new(version.release().iter().take(2));
let expr_python_version = MarkerExpression::Version {
key: MarkerValueVersion::PythonVersion,
specifier: VersionSpecifier::from_version(Operator::Equal, version_major_minor_only)
.unwrap(),
specifier: VersionSpecifier::from_version(
Operator::GreaterThanEqual,
version_major_minor_only,
)
.unwrap(),
};
let expr_python_full_version = MarkerExpression::Version {
key: MarkerValueVersion::PythonFullVersion,
specifier: VersionSpecifier::from_version(Operator::Equal, version).unwrap(),
specifier: VersionSpecifier::from_version(Operator::GreaterThanEqual, version).unwrap(),
};
MarkerTree::And(vec![
MarkerTree::Expression(expr_python_version),
Expand Down

0 comments on commit 9ac1a29

Please sign in to comment.