Skip to content

Commit dc23a60

Browse files
authored
Add support for requesting free-threaded builds via +freethreaded (#8645)
e.g., `uv python install 3.13+freethreaded` which matches the distribution keys.
1 parent 0044000 commit dc23a60

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

crates/uv-python/src/discovery.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -2074,11 +2074,30 @@ impl FromStr for VersionRequest {
20742074
// Split the release component if it uses the wheel tag format (e.g., `38`)
20752075
let version = split_wheel_tag_release_version(version);
20762076

2077-
// We dont allow post, dev, or local versions here
2078-
if version.post().is_some() || version.dev().is_some() || !version.local().is_empty() {
2077+
// We dont allow post or dev version here
2078+
if version.post().is_some() || version.dev().is_some() {
20792079
return Err(Error::InvalidVersionRequest(s.to_string()));
20802080
}
20812081

2082+
// Check if the local version includes a variant
2083+
let variant = if version.local().is_empty() {
2084+
variant
2085+
} else {
2086+
// If we already have a variant, do not allow another to be requested
2087+
if variant != PythonVariant::Default {
2088+
return Err(Error::InvalidVersionRequest(s.to_string()));
2089+
}
2090+
2091+
let [uv_pep440::LocalSegment::String(local)] = version.local() else {
2092+
return Err(Error::InvalidVersionRequest(s.to_string()));
2093+
};
2094+
2095+
match local.as_str() {
2096+
"freethreaded" => PythonVariant::Freethreaded,
2097+
_ => return Err(Error::InvalidVersionRequest(s.to_string())),
2098+
}
2099+
};
2100+
20822101
// Cast the release components into u8s since that's what we use in `VersionRequest`
20832102
let Ok(release) = try_into_u8_slice(version.release()) else {
20842103
return Err(Error::InvalidVersionRequest(s.to_string()));

0 commit comments

Comments
 (0)