I created a new project with uv 0.5.7:
uv init myproject
cd myproject
uv sync
And my project looks like this:
├── hello.py
├── pyproject.toml
├── README.md
└── uv.lock
At this point, the following works:
uv run python hello.py
uv run python -m hello
I would like to make a script name um by adding the following to pyproject.toml:
[project.scripts]
um = "hello:main"
However, that script is not found when I run it:
$ uv run um [umbala:main:]
error: Failed to spawn: `um`
Caused by: No such file or directory (os error 2)
I need help to create this script, um. What did I miss?
[project.scripts] is not uv-specific; as documented:
In this example, after installing your project, a
spam-clicommand will be available.
You'd need to uv pip install -e . your package, so the wrapper scripts are generated and placed in your (virtual)env's bin/ directory.
You might be missing a build system. uv requires a defined build system to determine whether to install the current project in the virtualenv. Something like this should work:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Using the entry point tables requires a build system to be defined. https://docs.astral.sh/uv/concepts/projects/config/#entry-points
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With