Skip to content

Commit

Permalink
uv init: --virtual should imply --no-package instead (#8595)
Browse files Browse the repository at this point in the history
## Summary

`uv init --virtual` should create a non-package project.
  • Loading branch information
j178 authored Oct 29, 2024
1 parent bf14b6a commit d9ea307
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl InitSettings {
(_, _, _) => unreachable!("`app`, `lib`, and `script` are mutually exclusive"),
};

let package = flag(package || build_backend.is_some() || r#virtual, no_package)
let package = flag(package || build_backend.is_some(), no_package || r#virtual)
.unwrap_or(kind.packaged_by_default());

Self {
Expand Down
33 changes: 6 additions & 27 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,22 +1601,15 @@ fn init_virtual_project() -> Result<()> {
filters => context.filters(),
}, {
assert_snapshot!(
pyproject, @r###"
pyproject, @r#"
[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
[project.scripts]
foo = "foo:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
"###
"#
);
});

Expand All @@ -1635,7 +1628,7 @@ fn init_virtual_project() -> Result<()> {
filters => context.filters(),
}, {
assert_snapshot!(
pyproject, @r###"
pyproject, @r#"
[project]
name = "foo"
version = "0.1.0"
Expand All @@ -1644,16 +1637,9 @@ fn init_virtual_project() -> Result<()> {
requires-python = ">=3.12"
dependencies = []
[project.scripts]
foo = "foo:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.uv.workspace]
members = ["bar"]
"###
"#
);
});

Expand Down Expand Up @@ -1730,22 +1716,15 @@ fn init_nested_virtual_workspace() -> Result<()> {
filters => context.filters(),
}, {
assert_snapshot!(
pyproject, @r###"
pyproject, @r#"
[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
[project.scripts]
foo = "foo:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
"###
"#
);
});

Expand Down

0 comments on commit d9ea307

Please sign in to comment.