An update on this after bookworm is already out: it seems that this is
still broken but in a slightly different variant.
The version of fastapi shipped now is 0.92, whereas the starlette
version is 0.26.1. The metadata for fastpi has a requirement that is not
satisfied:
$ grep starlette
/usr/lib/python3/dist-packages/fastapi-0.92.0.dist-info/METADATA
Requires-Dist: starlette<0.26.0,>=0.25.0
Using a minimal LXD container I could reproduce the issue by installing
a package with pip that depends only on fastapi:
$ apt install python3-fastapi python3-pip python3-venv
$ python3 -m venv --system-site-packages test_venv
$ . ./test_venv/bin/activate
$ pip install fastapi-restful-extension
Collecting fastapi-restful-extension
Using cached fastapi_restful_extension-0.4.2-py3-none-any.whl (6.6 kB)
Requirement already satisfied: fastapi>=0.78.0 in
/usr/lib/python3/dist-packages (from fastapi-restful-extension) (0.92.0)
Requirement already satisfied:
pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 in
/usr/lib/python3/dist-packages (from
fastapi>=0.78.0->fastapi-restful-extension) (1.10.4)
Collecting starlette<0.26.0,>=0.25.0
Downloading starlette-0.25.0-py3-none-any.whl (66 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.4/66.4 kB 929.9 kB/s
eta 0:00:00
Requirement already satisfied: anyio<5,>=3.4.0 in
/usr/lib/python3/dist-packages (from
starlette<0.26.0,>=0.25.0->fastapi>=0.78.0->fastapi-restful-extension)
(3.6.2)
Installing collected packages: starlette, fastapi-restful-extension
Attempting uninstall: starlette
Found existing installation: starlette 0.26.1
Not uninstalling starlette at /usr/lib/python3/dist-packages,
outside environment /root/test_venv
Can't uninstall 'starlette'. No files were found to uninstall.
Successfully installed fastapi-restful-extension-0.4.2 starlette-0.25.0
So pip recognizes that the situation is inconsistent. As before, pip
check would complain:
$ pip check
fastapi 0.92.0 has requirement starlette<0.26.0,>=0.25.0, but you have
starlette 0.26.1.
I am not sure which should be the best course of action. I can think of
two possible options:
- Relax the constrain in the metadata to allow also starlette <=0.26.1.
This might be a bit hacky, but it seems that the shipped starlette
0.26.1 is actually working fine with the shipped fastapi 0.92, at least
from a test I did with one small application that uses fastapi.
- Update the fastapi version to 0.94. This one introduces support for
starlette >=0.26.0. I have also tested the combination of 0.94 installed
from pip with starlette 0.26.1 from the bookworm repository and it seems
to work.