Add support for requesting free-threaded builds via +freethreaded (#8645)

e.g., `uv python install 3.13+freethreaded` which matches the
distribution keys.
This commit is contained in:
Zanie Blue 2024-10-28 15:22:49 -05:00 committed by GitHub
parent 0044000ed3
commit dc23a60277
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2074,11 +2074,30 @@ impl FromStr for VersionRequest {
// Split the release component if it uses the wheel tag format (e.g., `38`)
let version = split_wheel_tag_release_version(version);
// We dont allow post, dev, or local versions here
if version.post().is_some() || version.dev().is_some() || !version.local().is_empty() {
// We dont allow post or dev version here
if version.post().is_some() || version.dev().is_some() {
return Err(Error::InvalidVersionRequest(s.to_string()));
}
// Check if the local version includes a variant
let variant = if version.local().is_empty() {
variant
} else {
// If we already have a variant, do not allow another to be requested
if variant != PythonVariant::Default {
return Err(Error::InvalidVersionRequest(s.to_string()));
}
let [uv_pep440::LocalSegment::String(local)] = version.local() else {
return Err(Error::InvalidVersionRequest(s.to_string()));
};
match local.as_str() {
"freethreaded" => PythonVariant::Freethreaded,
_ => return Err(Error::InvalidVersionRequest(s.to_string())),
}
};
// Cast the release components into u8s since that's what we use in `VersionRequest`
let Ok(release) = try_into_u8_slice(version.release()) else {
return Err(Error::InvalidVersionRequest(s.to_string()));