diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index c5137dd11..26fc59f8c 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -599,7 +599,7 @@ impl InitProjectKind { if package { // Since it'll be packaged, we can add a `[project.scripts]` entry pyproject.push('\n'); - pyproject.push_str(&pyproject_project_scripts(name, "hello", "hello")); + pyproject.push_str(&pyproject_project_scripts(name, name.as_str(), "main")); // Add a build system pyproject.push('\n'); @@ -618,7 +618,7 @@ impl InitProjectKind { fs_err::write( init_py, indoc::formatdoc! {r#" - def hello() -> None: + def main() -> None: print("Hello from {name}!") "#}, )?; diff --git a/crates/uv/tests/init.rs b/crates/uv/tests/init.rs index a0dfe4749..f7c11ac26 100644 --- a/crates/uv/tests/init.rs +++ b/crates/uv/tests/init.rs @@ -282,7 +282,7 @@ fn init_application_package() -> Result<()> { dependencies = [] [project.scripts] - hello = "foo:hello" + foo = "foo:main" [build-system] requires = ["hatchling"] @@ -297,13 +297,13 @@ fn init_application_package() -> Result<()> { }, { assert_snapshot!( init, @r###" - def hello() -> None: + def main() -> None: print("Hello from foo!") "### ); }); - uv_snapshot!(context.filters(), context.run().current_dir(&child).arg("hello"), @r###" + uv_snapshot!(context.filters(), context.run().current_dir(&child).arg("foo"), @r###" success: true exit_code: 0 ----- stdout ----- @@ -1621,7 +1621,7 @@ fn init_virtual_project() -> Result<()> { dependencies = [] [project.scripts] - hello = "foo:hello" + foo = "foo:main" [build-system] requires = ["hatchling"] @@ -1655,7 +1655,7 @@ fn init_virtual_project() -> Result<()> { dependencies = [] [project.scripts] - hello = "foo:hello" + foo = "foo:main" [build-system] requires = ["hatchling"] @@ -1750,7 +1750,7 @@ fn init_nested_virtual_workspace() -> Result<()> { dependencies = [] [project.scripts] - hello = "foo:hello" + foo = "foo:main" [build-system] requires = ["hatchling"] diff --git a/docs/concepts/projects.md b/docs/concepts/projects.md index f9f0d0962..b46513fce 100644 --- a/docs/concepts/projects.md +++ b/docs/concepts/projects.md @@ -231,7 +231,7 @@ example-packaged-app But the module defines a CLI function: ```python title="__init__.py" -def hello() -> None: +def main() -> None: print("Hello from example-packaged-app!") ``` @@ -247,7 +247,7 @@ requires-python = ">=3.11" dependencies = [] [project.scripts] -hello = "example_packaged_app:hello" +example-packaged-app = "example_packaged_app:main" [build-system] requires = ["hatchling"] @@ -257,7 +257,7 @@ build-backend = "hatchling.build" Which can be executed with `uv run`: ```console -$ uv run hello +$ uv run example-packaged-app Hello from example-packaged-app! ```