From d2a9192e39b45ed6141e443caceedf6e750e0bba Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 23 May 2024 11:07:35 -0400 Subject: [PATCH] Avoid displaying log for satisfied editables if none are requested (#3795) e.g. in `uv pip install anyio -v` this message is just noise ``` DEBUG Requirement satisfied: anyio DEBUG Requirement satisfied: idna>=2.8 DEBUG Requirement satisfied: sniffio>=1.1 DEBUG All editables satisfied: ``` --- crates/uv/src/commands/pip/install.rs | 18 ++++++++++-------- crates/uv/src/commands/project/mod.rs | 13 +++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index ff0ae26a3..6b8203c2f 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -159,9 +159,9 @@ pub(crate) async fn pip_install( // Determine the set of installed packages. let site_packages = SitePackages::from_executable(&venv)?; - // If the requirements are already satisfied, we're done. Ideally, the resolver would be fast - // enough to let us remove this check. But right now, for large environments, it's an order of - // magnitude faster to validate the environment than to resolve the requirements. + // Check if the current environment satisfies the requirements. + // Ideally, the resolver would be fast enough to let us remove this check. But right now, for large environments, + // it's an order of magnitude faster to validate the environment than to resolve the requirements. if reinstall.is_none() && upgrade.is_none() && source_trees.is_empty() @@ -169,6 +169,7 @@ pub(crate) async fn pip_install( && uv_lock.is_none() { match site_packages.satisfies(&requirements, &editables, &constraints)? { + // If the requirements are already satisfied, we're done. SatisfiesResult::Fresh { recursive_requirements, } => { @@ -181,11 +182,12 @@ pub(crate) async fn pip_install( debug!("Requirement satisfied: {requirement}"); } } - - debug!( - "All editables satisfied: {}", - editables.iter().map(ToString::to_string).join(" | ") - ); + if !editables.is_empty() { + debug!( + "All editables satisfied: {}", + editables.iter().map(ToString::to_string).join(" | ") + ); + } let num_requirements = requirements.len() + editables.len(); let s = if num_requirements == 1 { "" } else { "s" }; writeln!( diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index ba9eaf290..b4b1ebca4 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -114,10 +114,9 @@ pub(crate) async fn update_environment( // Check if the current environment satisfies the requirements let site_packages = SitePackages::from_executable(&venv)?; - - // If the requirements are already satisfied, we're done. if spec.source_trees.is_empty() { match site_packages.satisfies(&spec.requirements, &spec.editables, &spec.constraints)? { + // If the requirements are already satisfied, we're done. SatisfiesResult::Fresh { recursive_requirements, } => { @@ -129,10 +128,12 @@ pub(crate) async fn update_environment( .sorted() .join(" | ") ); - debug!( - "All editables satisfied: {}", - spec.editables.iter().map(ToString::to_string).join(", ") - ); + if !spec.editables.is_empty() { + debug!( + "All editables satisfied: {}", + spec.editables.iter().map(ToString::to_string).join(", ") + ); + } return Ok(venv); } SatisfiesResult::Unsatisfied(requirement) => {