Skip to content

Conversation

tiangolo
Copy link
Member

🔧 Remove command script (entrypoint) fastapi, let it be provided by the fastapi package

Currently both fastapi-cli and fastapi provide a command fastapi.

The one in fastapi checks if fastapi-cli (this package) is installed and uses it. And if there's no fastapi-cli it tells the user that to use that command they need to install fastapi-cli. This is to improve the developer experience, if a user installs only fastapi and try to use the fastapi command, they would see an error from their shell of "command not found" or similar, not giving them any clue that they need to also install fastapi-cli, or better, install "fastapi[standard]".

But then, the functionality is really provided by fastapi-cli, so it also declared the same command fastapi.

This means that both the fastapi and fastapi-cli declare the same command, and one would override the other. Here, that override it wouldn't be a problem as in the end it's the same functionality from fastapi-cli the one that would be accessed.

And that behavior is, although weird, accepted in Python, mainly because pip (and other tools) can just override one command with the other.

Nevertheless, it's problematic for Linux distributions and others that re-pack the packages to be installed as part of distro packages, and those don't support overwriting commands as here.

...plus, it's still weird and strange that two packages declare the same command and would overwrite each other, not even in a deterministic way, it's not even obvious the command of which package would be the one that ends up installed. 😅

Having in mind the developer experience, I'm leaving the command declared in fastapi, and removing it from fastapi-cli.

It's also not very probable that someone would install only fastapi-cli, there's no reason to do it, so this should be a better default.

@tiangolo tiangolo added refactor bug Something isn't working and removed refactor labels Aug 31, 2025
@tiangolo tiangolo marked this pull request as ready for review August 31, 2025 16:31
@tiangolo tiangolo changed the title 🔧 Remove command script (entrypoint) fastapi, let it be provided by the fastapi package 🔧 Remove command script (entrypoint) fastapi, let it be provided by the fastapi package Aug 31, 2025
@tiangolo tiangolo changed the title 🔧 Remove command script (entrypoint) fastapi, let it be provided by the fastapi package 🔧 Remove command script fastapi, let it be provided by the fastapi package Aug 31, 2025
@tiangolo tiangolo merged commit 69cad3b into main Aug 31, 2025
21 of 22 checks passed
@tiangolo tiangolo deleted the no-script branch August 31, 2025 16:32
@lukehsiao
Copy link

lukehsiao commented Sep 2, 2025

Having in mind the developer experience, I'm leaving the command declared in fastapi, and removing it from fastapi-cli.

I'm still debugging, but I just updated my uv-based FastAPI project, which bumped to fastapi-cli 0.0.10, and now I see

❯ uv run fastapi --help
error: Failed to spawn: `fastapi`
  Caused by: No such file or directory (os error 2)

This is with "fastapi[all]~=0.116.0" as my dependency, currently on

❯ uv pip show fastapi
Name: fastapi
Version: 0.116.1

Just wanting to raise a flag that I believe this may have resulted in me losing the command.

Update: was able to fix by completely removing my virtualenv and rebuilding it. I'm guessing the command declared before was from fastapi-cli, not fastapi, so when this updated, the command pointed nowhere.

@thepowerfuldeez
Copy link

^ having the same problem here, setting fastapi-cli==0.0.8 as explicit dependency helps for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants