astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
19.15k stars 562 forks source link

Support custom tool entrypoints #3878

Open konstin opened 3 months ago

konstin commented 3 months ago

The package build doesn't install an entrypoint, you are supposed to call it as pythom -m build instead. pipx run build . while uv tool run build . fails. We should support whatever workaround pipx is using, too.

charliermarsh commented 3 months ago

I think build implements this special entrypoint thing for pipx exactly: https://github.com/pypa/build/blob/46337d95bcb6be84eb2b0416cff5bf51ba70d9c5/pyproject.toml#L84

njzjz commented 3 months ago

Workaround:

uv tool run --with build --from build python -m build

One may also want to use uv in the build: (the command is pretty long!)

uv tool run --with build[uv] --from build python -m build --installer uv
T-256 commented 1 month ago

Declaring custom entry points would be nice to support those projects didn't expose any entry point names and only allows to use them as module i.e python -m <mod>. I think this could be allowed in cli (which is support multiple use):

# make `cmd` available which runs `mod.__main__`
$ uvx --from pkg --with-script "cmd='mod.__main__'" cmd

Also, for build it turns to:

$ uvx --from build --with-script "build='build.__main__:entrypoint'" build
charliermarsh commented 1 month ago

You can already run uvx --from build pyproject-build

charliermarsh commented 1 month ago

And in the next version, we'll surface that this executable is available, which seems good...