astral-sh / uv

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

`uv tool install` unable to install a tool that depends on intermediate dependencies with entrypoints #4994

Open j178 opened 2 months ago

j178 commented 2 months ago

For instance, fastapi doesn't have any entrypoints but it depends on fastapi-cli, which provides an entrypoint named fastapi. uv tool install fastapi would result in a failure, displaying the error message No executables found for fastapi.

$ uv tool install fastapi
warning: `uv tool run` is experimental and may change without warning.
Resolved 36 packages in 729ms
Installed 36 packages in 92ms
...
 + fastapi==0.111.0
 + fastapi-cli==0.0.4
...
error: No executables found for `fastapi`

But at the same time uv tool run fastapi works:

$ uv tool run fastapi --version
warning: `uv tool run` is experimental and may change without warning.
Resolved 36 packages in 18ms
FastAPI CLI version: 0.0.4

Environment

os: Windows 11 Pro 23H2 (Build 22631.3737)
uv version: 0.2.24
zanieb commented 2 months ago

Interesting. I don't think we should install executables from dependencies by default, but we should allow opt-in.

j178 commented 2 months ago

rye tools install has a flag --include-dep <INCLUDE_DEP> to include scripts from a given dependency, maybe uv can allow something likes this.

zanieb commented 2 months ago

I actually won't take this on right away, I've got to take care of some other things first if someone is interested. I think we need something like:

I'm a little unsure of the name for the second one. Maybe:

For --executable, we need to decide if we'll scan dependencies if it's not found (we probably shouldn't for safety and performance but we could). If not, it's kind of separate from this issue.

We'll need to add included packages to the receipt, which is where most of the complexity is here.

charliermarsh commented 2 months ago

Why would this not be uv tool install fastapi-cli?

charliermarsh commented 2 months ago

And if fastapi-cli doesn't depend on fastapi, couldn't you do: uv tool install fastapi-cli --with fastapi?

charliermarsh commented 2 months ago

Although it seems like uvx fastapi --from fastapi-cli just works?

zanieb commented 2 months ago

Yeah uvx --from fastapi-cli fastapi ... does seem like the proper invocation here — but we would need to support including dependency entry points for parity with Rye and pipx.

charliermarsh commented 2 months ago

Yeah it just seems like it's kind of... the wrong way around, to include a dependency entrypoint. And it complicates the CLI a lot.

zanieb commented 2 months ago

I agree it's a bit awkward. I think we should pursue #5017 and #5018 to help guide users to the correct path here and we can consider implementing this more complicated API based on additional feedback.

charliermarsh commented 1 month ago

Ok, uv tool run jupyter is a counterexample here. Right now, we suggest uv tool run --from jupyter-core jupyter. And it's true that jupyter-core contains the Jupyer executable... but you also need jupyer installed in order to do, like, jupyter notebook. Otherwise, you get: Jupyter commandjupyter-notebooknot found.

So the command in that case would really need to be... uv tool run --from jupyter-core --with jupyter jupyter notebook.