Skip to content

Commit edb1744

Browse files
authored
Special-case == Python version request ranges (#9697)
Related to #9695 Doesn't solve the reported issue with `requires-python` because that doesn't go through the parser https://github.com/astral-sh/uv/blob/6ed6fc108e95e742075cf1eddb09ec86c04f632e/crates/uv/src/commands/project/mod.rs#L518-L526
1 parent f772f71 commit edb1744

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

crates/uv-python/src/discovery.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,6 +3324,11 @@ fn parse_version_specifiers_request(
33243324
if specifiers.is_empty() {
33253325
return Err(Error::InvalidVersionRequest(s.to_string()));
33263326
}
3327+
if let [specifier] = specifiers.iter().as_slice() {
3328+
if specifier.operator() == &uv_pep440::Operator::Equal {
3329+
return VersionRequest::from_str(&specifier.version().to_string());
3330+
}
3331+
}
33273332
Ok(VersionRequest::Range(specifiers, variant))
33283333
}
33293334

crates/uv/tests/it/python_find.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,3 +1513,26 @@ fn python_find_prerelease_with_patch_request() {
15131513
----- stderr -----
15141514
");
15151515
}
1516+
1517+
#[test]
1518+
fn python_find_equal() {
1519+
let context = uv_test::test_context_with_versions!(&["3.11", "3.12"]);
1520+
1521+
uv_snapshot!(context.filters(), context.python_find().arg("==3.11"), @r###"
1522+
success: true
1523+
exit_code: 0
1524+
----- stdout -----
1525+
[PYTHON-3.11]
1526+
1527+
----- stderr -----
1528+
"###);
1529+
1530+
uv_snapshot!(context.filters(), context.python_find().arg("==3.12"), @r###"
1531+
success: true
1532+
exit_code: 0
1533+
----- stdout -----
1534+
[PYTHON-3.12]
1535+
1536+
----- stderr -----
1537+
"###);
1538+
}

0 commit comments

Comments
 (0)