From d9ea30761571f14c94c56aa0aa5746d31bc0ac2c Mon Sep 17 00:00:00 2001 From: Jo <10510431+j178@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:42:14 +0800 Subject: [PATCH] uv init: `--virtual` should imply `--no-package` instead (#8595) ## Summary `uv init --virtual` should create a non-package project. --- crates/uv/src/settings.rs | 2 +- crates/uv/tests/it/init.rs | 33 ++++++--------------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 5b731cb6e..c520afe68 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -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 { diff --git a/crates/uv/tests/it/init.rs b/crates/uv/tests/it/init.rs index b085100f6..5a972fb49 100644 --- a/crates/uv/tests/it/init.rs +++ b/crates/uv/tests/it/init.rs @@ -1601,7 +1601,7 @@ fn init_virtual_project() -> Result<()> { filters => context.filters(), }, { assert_snapshot!( - pyproject, @r###" + pyproject, @r#" [project] name = "foo" version = "0.1.0" @@ -1609,14 +1609,7 @@ fn init_virtual_project() -> Result<()> { readme = "README.md" requires-python = ">=3.12" dependencies = [] - - [project.scripts] - foo = "foo:main" - - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - "### + "# ); }); @@ -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" @@ -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"] - "### + "# ); }); @@ -1730,7 +1716,7 @@ fn init_nested_virtual_workspace() -> Result<()> { filters => context.filters(), }, { assert_snapshot!( - pyproject, @r###" + pyproject, @r#" [project] name = "foo" version = "0.1.0" @@ -1738,14 +1724,7 @@ fn init_nested_virtual_workspace() -> Result<()> { readme = "README.md" requires-python = ">=3.12" dependencies = [] - - [project.scripts] - foo = "foo:main" - - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - "### + "# ); });