Allow multiple toolchains to be requested in uv toolchain install (#4334)

Allows installation of multiple toolchains in a single invocation
because I don't want to be limited to one! Most of the implementation
for concurrent downloads ported from `cargo dev fetch-python`.
This commit is contained in:
Zanie Blue 2024-06-17 14:24:11 -04:00 committed by GitHub
parent 4db6b902eb
commit fdcdc2cbe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 127 additions and 72 deletions

View file

@ -15,7 +15,7 @@ use uv_client::BetterReqwestError;
use futures::TryStreamExt;
use tokio_util::compat::FuturesAsyncReadCompatExt;
use tracing::debug;
use tracing::{debug, instrument};
use url::Url;
use uv_fs::Simplified;
@ -265,20 +265,30 @@ impl PythonDownloadRequest {
impl Display for PythonDownloadRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut parts = Vec::new();
if let Some(version) = &self.version {
parts.push(version.to_string());
}
if let Some(implementation) = self.implementation {
parts.push(implementation.to_string());
} else {
parts.push("any".to_string());
}
if let Some(version) = &self.version {
parts.push(version.to_string());
} else {
parts.push("any".to_string());
}
if let Some(os) = &self.os {
parts.push(os.to_string());
} else {
parts.push("any".to_string());
}
if let Some(arch) = self.arch {
parts.push(arch.to_string());
} else {
parts.push("any".to_string());
}
if let Some(libc) = self.libc {
parts.push(libc.to_string());
} else {
parts.push("any".to_string());
}
write!(f, "{}", parts.join("-"))
}
@ -371,6 +381,7 @@ impl PythonDownload {
}
/// Download and extract
#[instrument(skip(client, parent_path), fields(download = %self.key()))]
pub async fn fetch(
&self,
client: &uv_client::BaseClient,