From f35c7844514ab509f626b8a9c6745c52fc263251 Mon Sep 17 00:00:00 2001 From: Ahmed Ilyas Date: Mon, 30 Sep 2024 17:38:45 +0200 Subject: [PATCH] `uv build` builds into a top-level `dist` dir in workspaces --- crates/uv/src/commands/build.rs | 10 +++++++--- crates/uv/tests/build.rs | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/crates/uv/src/commands/build.rs b/crates/uv/src/commands/build.rs index 6bb42f3b2fe5..9e4e08e13c72 100644 --- a/crates/uv/src/commands/build.rs +++ b/crates/uv/src/commands/build.rs @@ -349,9 +349,13 @@ async fn build_package( let output_dir = if let Some(output_dir) = output_dir { Cow::Owned(std::path::absolute(output_dir)?) } else { - match &source.source { - Source::Directory(src) => Cow::Owned(src.join("dist")), - Source::File(src) => Cow::Borrowed(src.parent().unwrap()), + if let Ok(workspace) = workspace { + Cow::Owned(workspace.install_path().join("dist")) + } else { + match &source.source { + Source::Directory(src) => Cow::Owned(src.join("dist")), + Source::File(src) => Cow::Borrowed(src.parent().unwrap()), + } } }; diff --git a/crates/uv/tests/build.rs b/crates/uv/tests/build.rs index e7da73844c42..2c04f920bf5c 100644 --- a/crates/uv/tests/build.rs +++ b/crates/uv/tests/build.rs @@ -1041,21 +1041,21 @@ fn workspace() -> Result<()> { Copying src/member.egg-info to build/bdist.linux-x86_64/wheel/member-0.1.0-py3.12.egg-info running install_scripts creating build/bdist.linux-x86_64/wheel/member-0.1.0.dist-info/WHEEL - creating '[TEMP_DIR]/project/packages/member/dist/[TMP]/wheel' to it + creating '[TEMP_DIR]/project/dist/[TMP]/wheel' to it adding '__init__.py' adding 'member-0.1.0.dist-info/METADATA' adding 'member-0.1.0.dist-info/WHEEL' adding 'member-0.1.0.dist-info/top_level.txt' adding 'member-0.1.0.dist-info/RECORD' removing build/bdist.linux-x86_64/wheel - Successfully built packages/member/dist/member-0.1.0.tar.gz and packages/member/dist/member-0.1.0-py3-none-any.whl + Successfully built dist/member-0.1.0.tar.gz and dist/member-0.1.0-py3-none-any.whl "###); - member + project .child("dist") .child("member-0.1.0.tar.gz") .assert(predicate::path::is_file()); - member + project .child("dist") .child("member-0.1.0-py3-none-any.whl") .assert(predicate::path::is_file()); @@ -1071,15 +1071,15 @@ fn workspace() -> Result<()> { [PKG] Building source distribution... [PKG] Building wheel from source distribution... [PKG] Building wheel from source distribution... - Successfully built packages/member/dist/member-0.1.0.tar.gz and packages/member/dist/member-0.1.0-py3-none-any.whl + Successfully built dist/member-0.1.0.tar.gz and dist/member-0.1.0-py3-none-any.whl Successfully built dist/project-0.1.0.tar.gz and dist/project-0.1.0-py3-none-any.whl "###); - member + project .child("dist") .child("member-0.1.0.tar.gz") .assert(predicate::path::is_file()); - member + project .child("dist") .child("member-0.1.0-py3-none-any.whl") .assert(predicate::path::is_file()); @@ -1163,14 +1163,14 @@ fn workspace() -> Result<()> { Copying src/member.egg-info to build/bdist.linux-x86_64/wheel/member-0.1.0-py3.12.egg-info running install_scripts creating build/bdist.linux-x86_64/wheel/member-0.1.0.dist-info/WHEEL - creating '[TEMP_DIR]/project/packages/member/dist/[TMP]/wheel' to it + creating '[TEMP_DIR]/project/dist/[TMP]/wheel' to it adding '__init__.py' adding 'member-0.1.0.dist-info/METADATA' adding 'member-0.1.0.dist-info/WHEEL' adding 'member-0.1.0.dist-info/top_level.txt' adding 'member-0.1.0.dist-info/RECORD' removing build/bdist.linux-x86_64/wheel - Successfully built project/packages/member/dist/member-0.1.0.tar.gz and project/packages/member/dist/member-0.1.0-py3-none-any.whl + Successfully built project/dist/member-0.1.0.tar.gz and project/dist/member-0.1.0-py3-none-any.whl "###); // If a source is provided, discover the workspace from the source. @@ -1184,7 +1184,7 @@ fn workspace() -> Result<()> { [PKG] Building source distribution... [PKG] Building wheel from source distribution... [PKG] Building wheel from source distribution... - Successfully built project/packages/member/dist/member-0.1.0.tar.gz and project/packages/member/dist/member-0.1.0-py3-none-any.whl + Successfully built project/dist/member-0.1.0.tar.gz and project/dist/member-0.1.0-py3-none-any.whl Successfully built project/dist/project-0.1.0.tar.gz and project/dist/project-0.1.0-py3-none-any.whl "###); @@ -1327,7 +1327,7 @@ fn build_all_with_failure() -> Result<()> { [PKG] Building source distribution... [PKG] Building wheel from source distribution... [PKG] Building wheel from source distribution... - Successfully built packages/member_a/dist/member_a-0.1.0.tar.gz and packages/member_a/dist/member_a-0.1.0-py3-none-any.whl + Successfully built dist/member_a-0.1.0.tar.gz and dist/member_a-0.1.0-py3-none-any.whl [PKG] error: Build backend failed to determine extra requires with `build_sdist()` with exit status: 1 Successfully built dist/project-0.1.0.tar.gz and dist/project-0.1.0-py3-none-any.whl "###); @@ -1342,11 +1342,11 @@ fn build_all_with_failure() -> Result<()> { .child("project-0.1.0-py3-none-any.whl") .assert(predicate::path::is_file()); - member_a + project .child("dist") .child("member_a-0.1.0.tar.gz") .assert(predicate::path::is_file()); - member_a + project .child("dist") .child("member_a-0.1.0-py3-none-any.whl") .assert(predicate::path::is_file());