mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Avoid showing resolver progress bar when no resolution is required (#133)
This commit is contained in:
parent
573f5832a3
commit
20bb4c5c61
1 changed files with 17 additions and 10 deletions
|
@ -15,6 +15,7 @@ use puffin_installer::{LocalDistribution, LocalIndex, RemoteDistribution};
|
|||
use puffin_interpreter::{PythonExecutable, SitePackages};
|
||||
use puffin_package::package_name::PackageName;
|
||||
use puffin_package::requirements_txt::RequirementsTxt;
|
||||
use puffin_resolver::Resolution;
|
||||
|
||||
use crate::commands::reporters::{
|
||||
DownloadReporter, InstallReporter, UnzipReporter, WheelFinderReporter,
|
||||
|
@ -62,6 +63,7 @@ pub(crate) async fn sync_requirements(
|
|||
flags: PipSyncFlags,
|
||||
mut printer: Printer,
|
||||
) -> Result<ExitStatus> {
|
||||
// Audit the requirements.
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
// Detect the current Python interpreter.
|
||||
|
@ -99,11 +101,15 @@ pub(crate) async fn sync_requirements(
|
|||
let client = PypiClientBuilder::default().cache(cache).build();
|
||||
|
||||
// Resolve the dependencies.
|
||||
let wheel_finder = puffin_resolver::WheelFinder::new(&tags, &client)
|
||||
.with_reporter(WheelFinderReporter::from(printer).with_length(uncached.len() as u64));
|
||||
let resolution = wheel_finder.resolve(&uncached).await?;
|
||||
let resolution = if uncached.is_empty() {
|
||||
Resolution::default()
|
||||
} else {
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
let wheel_finder = puffin_resolver::WheelFinder::new(&tags, &client)
|
||||
.with_reporter(WheelFinderReporter::from(printer).with_length(uncached.len() as u64));
|
||||
let resolution = wheel_finder.resolve(&uncached).await?;
|
||||
|
||||
if !resolution.is_empty() {
|
||||
let s = if resolution.len() == 1 { "" } else { "s" };
|
||||
writeln!(
|
||||
printer,
|
||||
|
@ -115,9 +121,9 @@ pub(crate) async fn sync_requirements(
|
|||
)
|
||||
.dimmed()
|
||||
)?;
|
||||
}
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
resolution
|
||||
};
|
||||
|
||||
let uncached = resolution
|
||||
.into_files()
|
||||
|
@ -129,6 +135,8 @@ pub(crate) async fn sync_requirements(
|
|||
let downloads = if uncached.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
let downloader = puffin_installer::Downloader::new(&client, cache)
|
||||
.with_reporter(DownloadReporter::from(printer).with_length(uncached.len() as u64));
|
||||
|
||||
|
@ -151,12 +159,12 @@ pub(crate) async fn sync_requirements(
|
|||
downloads
|
||||
};
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
// Unzip any downloaded distributions.
|
||||
let unzips = if downloads.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
let unzipper = puffin_installer::Unzipper::default()
|
||||
.with_reporter(UnzipReporter::from(printer).with_length(downloads.len() as u64));
|
||||
|
||||
|
@ -180,9 +188,8 @@ pub(crate) async fn sync_requirements(
|
|||
unzips
|
||||
};
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
// Install the resolved distributions.
|
||||
let start = std::time::Instant::now();
|
||||
let wheels = unzips.into_iter().chain(cached).collect::<Vec<_>>();
|
||||
puffin_installer::Installer::new(&python)
|
||||
.with_reporter(InstallReporter::from(printer).with_length(wheels.len() as u64))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue