diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index ec1f42548..6ccbb91b2 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -2032,7 +2032,11 @@ pub(crate) async fn update_environment( // Check if the current environment satisfies the requirements let site_packages = SitePackages::from_environment(&venv)?; - if source_trees.is_empty() && reinstall.is_none() && upgrade.is_none() { + if reinstall.is_none() + && upgrade.is_none() + && source_trees.is_empty() + && matches!(modifications, Modifications::Sufficient) + { match site_packages.satisfies_spec(&requirements, &constraints, &overrides, &marker_env)? { // If the requirements are already satisfied, we're done. SatisfiesResult::Fresh { diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 9996ba48c..e07e4379b 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -3962,6 +3962,8 @@ fn sync_active_script_environment() -> Result<()> { ----- stderr ----- Using script environment at: foo + Resolved 3 packages in [TIME] + Audited 3 packages in [TIME] "###); // Requesting another Python version will invalidate the environment @@ -7598,13 +7600,12 @@ fn sync_script() -> Result<()> { + iniconfig==2.0.0 "); - // Modify the `requires-python`. + // Remove a dependency. script.write_str(indoc! { r#" # /// script - # requires-python = ">=3.8, <3.11" + # requires-python = ">=3.11" # dependencies = [ # "anyio", - # "iniconfig", # ] # /// @@ -7612,23 +7613,47 @@ fn sync_script() -> Result<()> { "# })?; - uv_snapshot!(&filters, context.sync().arg("--script").arg("script.py"), @r" + uv_snapshot!(&filters, context.sync().arg("--script").arg("script.py"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Using script environment at: [CACHE_DIR]/environments-v2/script-[HASH] + Resolved 3 packages in [TIME] + Uninstalled 1 package in [TIME] + - iniconfig==2.0.0 + "###); + + // Modify the `requires-python`. + script.write_str(indoc! { r#" + # /// script + # requires-python = ">=3.8, <3.11" + # dependencies = [ + # "anyio", + # ] + # /// + + import anyio + "# + })?; + + uv_snapshot!(&filters, context.sync().arg("--script").arg("script.py"), @r###" success: true exit_code: 0 ----- stdout ----- ----- stderr ----- Recreating script environment at: [CACHE_DIR]/environments-v2/script-[HASH] - Resolved 6 packages in [TIME] + Resolved 5 packages in [TIME] Prepared 2 packages in [TIME] - Installed 6 packages in [TIME] + Installed 5 packages in [TIME] + anyio==4.3.0 + exceptiongroup==1.2.0 + idna==3.6 - + iniconfig==2.0.0 + sniffio==1.3.1 + typing-extensions==4.10.0 - "); + "###); // `--locked` and `--frozen` should fail with helpful error messages. uv_snapshot!(&filters, context.sync().arg("--script").arg("script.py").arg("--locked"), @r" diff --git a/crates/uv/tests/it/tool_install.rs b/crates/uv/tests/it/tool_install.rs index 8dcf9969d..fbedc46d0 100644 --- a/crates/uv/tests/it/tool_install.rs +++ b/crates/uv/tests/it/tool_install.rs @@ -563,6 +563,8 @@ fn tool_install_editable() { ----- stdout ----- ----- stderr ----- + Resolved 1 package in [TIME] + Audited 1 package in [TIME] Installed 1 executable: black "###); @@ -2201,6 +2203,8 @@ fn tool_install_upgrade() { ----- stdout ----- ----- stderr ----- + Resolved [N] packages in [TIME] + Audited [N] packages in [TIME] Installed 2 executables: black, blackd "###); @@ -3190,6 +3194,8 @@ fn tool_install_at_latest_upgrade() { ----- stdout ----- ----- stderr ----- + Resolved [N] packages in [TIME] + Audited [N] packages in [TIME] Installed 2 executables: black, blackd "###);