Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure a script path? #6998

Closed
TiansuYu opened this issue Sep 4, 2024 · 3 comments · Fixed by #7010
Closed

How to configure a script path? #6998

TiansuYu opened this issue Sep 4, 2024 · 3 comments · Fixed by #7010
Labels
question Asking for clarification or support

Comments

@TiansuYu
Copy link

TiansuYu commented Sep 4, 2024

I am building a CLI tool and tries to bind the script path to cli name. e.g. in Poetry this is https://python-poetry.org/docs/pyproject/#scripts. However, I could not find any instructions on how to do this in UV. Could you enlighten me please?

@bwt-sloanj
Copy link

With uv this can just be done via the normal [project] table in the pyproject.toml file. https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts

@zanieb zanieb added the question Asking for clarification or support label Sep 4, 2024
@TiansuYu
Copy link
Author

TiansuYu commented Sep 4, 2024

I have a project that i want to add a script entrypoint to run src/xyz/main.py:main (main() function inside src/xyz/main.py), and my section in pyproject.toml looks like this

[project.scripts]
xyz = "src.xyz.main:main"

uv errors out with

-> % uv run xyz
error: Failed to spawn: `xyz`
  Caused by: No such file or directory (os error 2)

The error messages looks a bit cryptic for me to understand how have I configured the path wrong.

@zanieb
Copy link
Member

zanieb commented Sep 4, 2024

Do you have a [build-system] defined for your project? (https://docs.astral.sh/uv/concepts/projects/#build-systems)

zanieb added a commit that referenced this issue Sep 4, 2024
Closes #6998

Common point of confusion because Poetry defines these in
`tool.poetry.scripts`
lucab added a commit that referenced this issue Sep 16, 2024
…7420)

This enhances `uv sync` logic in order to detect and warn if it is
trying to operate on a packaged project with entrypoints.

Ref: #6998 (comment)
Closes: #7034
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants