mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-21 15:52:15 +00:00
Add progress bar when downloading python (#4840)
## Summary Resolves #4825 ## Test Plan ```sh $ cargo run -- python install --force --preview $ cargo run -- venv -p 3.12 --python-preference only-managed $ cargo run -- tool install --preview -p 3.12 --python-preference only-managed --force black ```` --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
9e50864508
commit
f4c4b69cc7
12 changed files with 220 additions and 59 deletions
|
@ -10,7 +10,7 @@ use uv_cache::Cache;
|
|||
use crate::discovery::{
|
||||
find_best_python_installation, find_python_installation, EnvironmentPreference, PythonRequest,
|
||||
};
|
||||
use crate::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequest};
|
||||
use crate::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequest, Reporter};
|
||||
use crate::implementation::LenientImplementationName;
|
||||
use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations};
|
||||
use crate::platform::{Arch, Libc, Os};
|
||||
|
@ -82,13 +82,14 @@ impl PythonInstallation {
|
|||
python_fetch: PythonFetch,
|
||||
client_builder: &BaseClientBuilder<'a>,
|
||||
cache: &Cache,
|
||||
reporter: Option<&dyn Reporter>,
|
||||
) -> Result<Self, Error> {
|
||||
let request = request.unwrap_or_default();
|
||||
|
||||
// Perform a fetch aggressively if managed Python is preferred
|
||||
if matches!(preference, PythonPreference::Managed) && python_fetch.is_automatic() {
|
||||
if let Some(request) = PythonDownloadRequest::try_from_request(&request) {
|
||||
return Self::fetch(request.fill(), client_builder, cache).await;
|
||||
return Self::fetch(request.fill(), client_builder, cache, reporter).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +104,7 @@ impl PythonInstallation {
|
|||
{
|
||||
if let Some(request) = PythonDownloadRequest::try_from_request(&request) {
|
||||
debug!("Requested Python not found, checking for available download...");
|
||||
Self::fetch(request.fill(), client_builder, cache).await
|
||||
Self::fetch(request.fill(), client_builder, cache, reporter).await
|
||||
} else {
|
||||
err
|
||||
}
|
||||
|
@ -117,6 +118,7 @@ impl PythonInstallation {
|
|||
request: PythonDownloadRequest,
|
||||
client_builder: &BaseClientBuilder<'a>,
|
||||
cache: &Cache,
|
||||
reporter: Option<&dyn Reporter>,
|
||||
) -> Result<Self, Error> {
|
||||
let installations = ManagedPythonInstallations::from_settings()?.init()?;
|
||||
let installations_dir = installations.root();
|
||||
|
@ -126,7 +128,7 @@ impl PythonInstallation {
|
|||
let client = client_builder.build();
|
||||
|
||||
info!("Fetching requested Python...");
|
||||
let result = download.fetch(&client, installations_dir).await?;
|
||||
let result = download.fetch(&client, installations_dir, reporter).await?;
|
||||
|
||||
let path = match result {
|
||||
DownloadResult::AlreadyAvailable(path) => path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue