From 05d79f8d38949b9f8a45e55ba885d2ae4a342b6e Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Mon, 17 Jun 2024 14:38:34 -0400 Subject: [PATCH] Remove extraneous installations in `uv sync` by default (#4366) ## Summary First step of https://github.com/astral-sh/uv/issues/4358. `uv sync` will now remove any extraneous installations by default. --- crates/uv/src/commands/project/sync.rs | 2 +- crates/uv/tests/edit.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 5fbae7a24..e64569a57 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -188,7 +188,7 @@ pub(super) async fn do_sync( pip::operations::install( &resolution, site_packages, - Modifications::Sufficient, + Modifications::Exact, reinstall, build_options, *link_mode, diff --git a/crates/uv/tests/edit.rs b/crates/uv/tests/edit.rs index 4b43a8686..37607fb75 100644 --- a/crates/uv/tests/edit.rs +++ b/crates/uv/tests/edit.rs @@ -691,10 +691,13 @@ fn remove_registry() -> Result<()> { warning: `uv remove` is experimental and may change without warning. Resolved 1 package in [TIME] Downloaded 1 package in [TIME] - Uninstalled 1 package in [TIME] + Uninstalled 4 packages in [TIME] Installed 1 package in [TIME] + - anyio==3.7.0 + - idna==3.6 - project==0.1.0 (from file://[TEMP_DIR]/) + project==0.1.0 (from file://[TEMP_DIR]/) + - sniffio==1.3.1 "###); let pyproject_toml = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?; @@ -808,10 +811,13 @@ fn remove_dev() -> Result<()> { warning: `uv remove` is experimental and may change without warning. Resolved 1 package in [TIME] Downloaded 1 package in [TIME] - Uninstalled 1 package in [TIME] + Uninstalled 4 packages in [TIME] Installed 1 package in [TIME] + - anyio==3.7.0 + - idna==3.6 - project==0.1.0 (from file://[TEMP_DIR]/) + project==0.1.0 (from file://[TEMP_DIR]/) + - sniffio==1.3.1 "###); let pyproject_toml = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?; @@ -917,10 +923,13 @@ fn remove_all_registry() -> Result<()> { warning: `uv remove` is experimental and may change without warning. Resolved 1 package in [TIME] Downloaded 1 package in [TIME] - Uninstalled 1 package in [TIME] + Uninstalled 4 packages in [TIME] Installed 1 package in [TIME] + - anyio==3.7.0 + - idna==3.6 - project==0.1.0 (from file://[TEMP_DIR]/) + project==0.1.0 (from file://[TEMP_DIR]/) + - sniffio==1.3.1 "###); let pyproject_toml = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?;