Skip to content

Commit

Permalink
Add support for requesting free-threaded builds via +freethreaded (#…
Browse files Browse the repository at this point in the history
…8645)

e.g., `uv python install 3.13+freethreaded` which matches the
distribution keys.
  • Loading branch information
zanieb authored Oct 28, 2024
1 parent 0044000 commit dc23a60
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions crates/uv-python/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit dc23a60

Please sign in to comment.