mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-01 14:31:12 +00:00
Allow uv init
in unmanaged projects (#5372)
## Summary Closes https://github.com/astral-sh/uv/issues/5368.
This commit is contained in:
parent
c271eda6b6
commit
4863ec8b5b
2 changed files with 39 additions and 0 deletions
|
@ -94,6 +94,7 @@ pub(crate) async fn init(
|
||||||
{
|
{
|
||||||
Ok(workspace) => Some(workspace),
|
Ok(workspace) => Some(workspace),
|
||||||
Err(WorkspaceError::MissingPyprojectToml) => None,
|
Err(WorkspaceError::MissingPyprojectToml) => None,
|
||||||
|
Err(WorkspaceError::NonWorkspace(_)) => None,
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1043,3 +1043,41 @@ fn init_requires_python_specifiers() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Run `uv init` from within an unmanaged project.
|
||||||
|
#[test]
|
||||||
|
fn init_unmanaged() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||||
|
pyproject_toml.write_str(indoc! {
|
||||||
|
r"
|
||||||
|
[tool.uv]
|
||||||
|
managed = false
|
||||||
|
",
|
||||||
|
})?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), context.init().arg("foo"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
warning: `uv init` is experimental and may change without warning
|
||||||
|
Initialized project `foo` at `[TEMP_DIR]/foo`
|
||||||
|
"###);
|
||||||
|
|
||||||
|
let workspace = fs_err::read_to_string(context.temp_dir.join("pyproject.toml"))?;
|
||||||
|
insta::with_settings!({
|
||||||
|
filters => context.filters(),
|
||||||
|
}, {
|
||||||
|
assert_snapshot!(
|
||||||
|
workspace, @r###"
|
||||||
|
[tool.uv]
|
||||||
|
managed = false
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue