diff --git a/crates/puffin-cli/src/commands/pip_sync.rs b/crates/puffin-cli/src/commands/pip_sync.rs index 5d8c97976..7b7b0e29a 100644 --- a/crates/puffin-cli/src/commands/pip_sync.rs +++ b/crates/puffin-cli/src/commands/pip_sync.rs @@ -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 { + // 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::>(); puffin_installer::Installer::new(&python) .with_reporter(InstallReporter::from(printer).with_length(wheels.len() as u64))