Skip to content

Commit

Permalink
Allow uv pip install for unmanaged projects (#5504)
Browse files Browse the repository at this point in the history
## Summary

Just an oversight.

Closes: #5500.
  • Loading branch information
charliermarsh authored Jul 27, 2024
1 parent 24859bd commit 866d844
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
9 changes: 6 additions & 3 deletions crates/uv-workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,12 @@ impl ProjectWorkspace {
return Ok(None);
};

Ok(Some(
Self::from_project(install_path, lock_path, &project, &pyproject_toml, options).await?,
))
match Self::from_project(install_path, lock_path, &project, &pyproject_toml, options).await
{
Ok(workspace) => Ok(Some(workspace)),
Err(WorkspaceError::NonWorkspace(_)) => Ok(None),
Err(err) => Err(err),
}
}

/// Returns the directory containing the closest `pyproject.toml` that defines the current
Expand Down
37 changes: 37 additions & 0 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6151,3 +6151,40 @@ fn accept_existing_prerelease() -> Result<()> {

Ok(())
}

/// Allow `pip install` of an unmanaged project.
#[test]
fn unmanaged() -> Result<()> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"[project]
name = "example"
version = "0.0.0"
dependencies = [
"anyio==3.7.0"
]
[tool.uv]
managed = false
"#,
)?;

uv_snapshot!(context.filters(), context.pip_install().arg("."), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 4 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==3.7.0
+ example==0.0.0 (from file://[TEMP_DIR]/)
+ idna==3.6
+ sniffio==1.3.1
"###
);

Ok(())
}
10 changes: 6 additions & 4 deletions crates/uv/tests/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ fn test_albatross_project_in_excluded() {
.join("packages")
.join("seeds");
uv_snapshot!(context.filters(), install_workspace(&context, &current_dir), @r###"
success: false
exit_code: 2
success: true
exit_code: 0
----- stdout -----
----- stderr -----
error: Failed to download and build: `seeds @ file://[WORKSPACE]/scripts/workspaces/albatross-project-in-excluded/packages/seeds`
Caused by: The project is marked as unmanaged: `[WORKSPACE]/scripts/workspaces/albatross-project-in-excluded/packages/seeds`
Resolved 2 packages in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ seeds==1.0.0 (from file://[WORKSPACE]/scripts/workspaces/albatross-project-in-excluded/packages/seeds)
"###
);
}
Expand Down

0 comments on commit 866d844

Please sign in to comment.