Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/uv-workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ impl Workspace {
let path = std::path::absolute(path)
.map_err(WorkspaceError::Normalize)?
.clone();
// Remove `.` and `..`
let path = uv_fs::normalize_path(&path);
// Trim trailing slashes.
let path = path.components().collect::<PathBuf>();

let project_path = path
.ancestors()
Expand Down Expand Up @@ -1363,6 +1367,10 @@ impl ProjectWorkspace {
let project_path = std::path::absolute(install_path)
.map_err(WorkspaceError::Normalize)?
.clone();
// Remove `.` and `..`
let project_path = uv_fs::normalize_path(&project_path);
// Trim trailing slashes.
let project_path = project_path.components().collect::<PathBuf>();

// Check if workspaces are explicitly disabled for the project.
if project_pyproject_toml
Expand Down
62 changes: 62 additions & 0 deletions crates/uv/tests/it/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2084,3 +2084,65 @@ fn venv_included_in_sdist() -> Result<()> {

Ok(())
}

/// Ensure that workspace discovery works with and without trailing slash.
///
/// <https://github.com/astral-sh/uv/issues/13914>
#[test]
fn test_workspace_trailing_slash() {
let context = TestContext::new("3.12");

// Create a workspace with a root and a member.
context.init().arg("--lib").assert().success();
context.init().arg("--lib").arg("child").assert().success();

uv_snapshot!(context.filters(), context.build().arg("child"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Building source distribution (uv build backend)...
Building wheel from source distribution (uv build backend)...
Successfully built dist/child-0.1.0.tar.gz
Successfully built dist/child-0.1.0-py3-none-any.whl
");

// Check that workspace discovery still works.
uv_snapshot!(context.filters(), context.build().arg("child/"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Building source distribution (uv build backend)...
Building wheel from source distribution (uv build backend)...
Successfully built dist/child-0.1.0.tar.gz
Successfully built dist/child-0.1.0-py3-none-any.whl
");

// Check general normalization too.
uv_snapshot!(context.filters(), context.build().arg("./child/"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Building source distribution (uv build backend)...
Building wheel from source distribution (uv build backend)...
Successfully built dist/child-0.1.0.tar.gz
Successfully built dist/child-0.1.0-py3-none-any.whl
");

uv_snapshot!(context.filters(), context.build().arg("./child/../child/"), @r"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Building source distribution (uv build backend)...
Building wheel from source distribution (uv build backend)...
Successfully built dist/child-0.1.0.tar.gz
Successfully built dist/child-0.1.0-py3-none-any.whl
");
}
Loading