From 85d9b5b62b32eb3d15785edfc9e186f73acdacd9 Mon Sep 17 00:00:00 2001 From: John Mumm Date: Tue, 8 Jul 2025 15:49:19 +0200 Subject: [PATCH] Build workspace member sources by default --- .../uv-distribution/src/metadata/lowering.rs | 4 +- crates/uv/tests/it/lock.rs | 4 +- crates/uv/tests/it/lock_conflict.rs | 40 ++++++++++--------- crates/uv/tests/it/pip_compile.rs | 12 +++--- crates/uv/tests/it/sync.rs | 5 ++- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/crates/uv-distribution/src/metadata/lowering.rs b/crates/uv-distribution/src/metadata/lowering.rs index c05ac4779..a9d8e3d81 100644 --- a/crates/uv-distribution/src/metadata/lowering.rs +++ b/crates/uv-distribution/src/metadata/lowering.rs @@ -306,7 +306,9 @@ impl LoweredRequirement { }, url, } - } else if member.pyproject_toml().is_package() { + // Workspace member sources should be built by default unless they are explicitly marked + // as `tool.uv.package = false`. + } else if member.pyproject_toml().tool_uv_package().unwrap_or(true) { RequirementSource::Directory { install_path: install_path.into_boxed_path(), url, diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 37eae1b7e..d92e1c161 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -12041,7 +12041,7 @@ fn lock_remove_member() -> Result<()> { [[package]] name = "leaf" version = "0.1.0" - source = { virtual = "leaf" } + source = { editable = "leaf" } dependencies = [ { name = "anyio" }, ] @@ -12058,7 +12058,7 @@ fn lock_remove_member() -> Result<()> { ] [package.metadata] - requires-dist = [{ name = "leaf", virtual = "leaf" }] + requires-dist = [{ name = "leaf", editable = "leaf" }] [[package]] name = "sniffio" diff --git a/crates/uv/tests/it/lock_conflict.rs b/crates/uv/tests/it/lock_conflict.rs index bf1bc1eac..d67736c88 100644 --- a/crates/uv/tests/it/lock_conflict.rs +++ b/crates/uv/tests/it/lock_conflict.rs @@ -1094,18 +1094,19 @@ fn extra_unconditional() -> Result<()> { "###); // This is fine because we are only enabling one // extra, and thus, there is no conflict. - uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r###" + uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r" success: true exit_code: 0 ----- stdout ----- ----- stderr ----- - Prepared 3 packages in [TIME] - Installed 3 packages in [TIME] + Prepared 4 packages in [TIME] + Installed 4 packages in [TIME] + anyio==4.1.0 + idna==3.6 + + proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1) + sniffio==1.3.1 - "###); + "); // And same thing for the other extra. root_pyproject_toml.write_str( @@ -1215,18 +1216,19 @@ fn extra_unconditional_non_conflicting() -> Result<()> { // `uv sync` wasn't correctly propagating extras in a way // that would satisfy the conflict markers that got added // to the `proxy1[extra1]` dependency. - uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r###" + uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r" success: true exit_code: 0 ----- stdout ----- ----- stderr ----- - Prepared 3 packages in [TIME] - Installed 3 packages in [TIME] + Prepared 4 packages in [TIME] + Installed 4 packages in [TIME] + anyio==4.1.0 + idna==3.6 + + proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1) + sniffio==1.3.1 - "###); + "); Ok(()) } @@ -1301,16 +1303,17 @@ fn extra_unconditional_in_optional() -> Result<()> { "###); // This should install `sortedcontainers==2.3.0`. - uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x1"), @r###" + uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x1"), @r" success: true exit_code: 0 ----- stdout ----- ----- stderr ----- - Prepared 1 package in [TIME] - Installed 1 package in [TIME] + Prepared 2 packages in [TIME] + Installed 2 packages in [TIME] + + proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1) + sortedcontainers==2.3.0 - "###); + "); // This should install `sortedcontainers==2.4.0`. uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x2"), @r###" @@ -4460,19 +4463,20 @@ conflicts = [ error: Extra `x2` is not defined in the project's `optional-dependencies` table "###); - uv_snapshot!(context.filters(), context.sync(), @r###" + uv_snapshot!(context.filters(), context.sync(), @r" success: true exit_code: 0 ----- stdout ----- ----- stderr ----- Resolved 7 packages in [TIME] - Prepared 3 packages in [TIME] - Installed 3 packages in [TIME] + Prepared 4 packages in [TIME] + Installed 4 packages in [TIME] + anyio==4.3.0 + idna==3.6 + + proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1) + sniffio==1.3.1 - "###); + "); let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap(); insta::with_settings!({ @@ -4558,14 +4562,14 @@ conflicts = [ requires-dist = [ { name = "anyio", specifier = ">=4" }, { name = "idna", marker = "extra == 'x1'", specifier = "==3.6" }, - { name = "proxy1", virtual = "proxy1" }, + { name = "proxy1", editable = "proxy1" }, ] provides-extras = ["x1"] [[package]] name = "proxy1" version = "0.1.0" - source = { virtual = "proxy1" } + source = { editable = "proxy1" } [package.optional-dependencies] x2 = [ diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index ac3549874..69da12fd6 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -15772,18 +15772,18 @@ fn project_and_group_workspace_inherit() -> Result<()> { ----- stdout ----- # This file was autogenerated by uv via the following command: # uv pip compile --cache-dir [CACHE_DIR] --group packages/mysubproject/pyproject.toml:foo + -e file://[TEMP_DIR]/packages/pytest + # via mysubproject (packages/mysubproject/pyproject.toml:foo) + -e file://[TEMP_DIR]/packages/sniffio + # via + # mysubproject (packages/mysubproject/pyproject.toml:foo) + # anyio anyio==4.3.0 # via mysubproject (packages/mysubproject/pyproject.toml:foo) idna==3.6 # via anyio iniconfig==2.0.0 # via mysubproject (packages/mysubproject/pyproject.toml:foo) - pytest @ file://[TEMP_DIR]/packages/pytest - # via mysubproject (packages/mysubproject/pyproject.toml:foo) - sniffio @ file://[TEMP_DIR]/packages/sniffio - # via - # mysubproject (packages/mysubproject/pyproject.toml:foo) - # anyio ----- stderr ----- Resolved 5 packages in [TIME] diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 78ff5efb0..535a4aac7 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -3626,9 +3626,10 @@ fn sync_non_existent_extra_workspace_member() -> Result<()> { ----- stderr ----- Resolved 5 packages in [TIME] - Prepared 3 packages in [TIME] - Installed 3 packages in [TIME] + Prepared 4 packages in [TIME] + Installed 4 packages in [TIME] + anyio==4.3.0 + + child==0.1.0 (from file://[TEMP_DIR]/child) + idna==3.6 + sniffio==1.3.1 ");