Skip to content

Commit

Permalink
⬇️ Separate requirements for development into their own requirements.…
Browse files Browse the repository at this point in the history
…txt files, they shouldn't be extras (#9655)
  • Loading branch information
tiangolo committed Jun 11, 2023
1 parent c8b729a commit 6595658
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v03
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[doc]
run: pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -e .[all,dev,doc,test]
run: pip install -r requirements-tests.txt
- name: Lint
run: bash scripts/lint.sh
- run: mkdir coverage
Expand Down
2 changes: 1 addition & 1 deletion docs/em/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $ python -m pip install --upgrade pip
<div class="termy">

```console
$ pip install -e ."[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand Down
9 changes: 7 additions & 2 deletions docs/en/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ After activating the environment as described above:
<div class="termy">

```console
$ pip install -e ".[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand All @@ -121,10 +121,15 @@ It will install all the dependencies and your local FastAPI in your local enviro

If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your local FastAPI source code.

And if you update that local FastAPI source code, as it is installed with `-e`, when you run that Python file again, it will use the fresh version of FastAPI you just edited.
And if you update that local FastAPI source code when you run that Python file again, it will use the fresh version of FastAPI you just edited.

That way, you don't have to "install" your local version to be able to test every change.

!!! note "Technical Details"
This only happens when you install using this included `requiements.txt` instead of installing `pip install fastapi` directly.

That is because inside of the `requirements.txt` file, the local version of FastAPI is marked to be installed in "editable" mode, with the `-e` option.

### Format

There is a script that you can run that will format and clean all your code:
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ python -m venv env
<div class="termy">

```console
$ pip install -e ."[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand Down
2 changes: 1 addition & 1 deletion docs/pt/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Após ativar o ambiente como descrito acima:
<div class="termy">

```console
$ pip install -e ."[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $ python -m pip install --upgrade pip
<div class="termy">

```console
$ pip install -e ."[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ python -m venv env
<div class="termy">

```console
$ pip install -e ."[dev,doc,test]"
$ pip install -r requirements.txt

---> 100%
```
Expand Down
41 changes: 0 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,6 @@ Homepage = "https://github.com/tiangolo/fastapi"
Documentation = "https://fastapi.tiangolo.com/"

[project.optional-dependencies]
test = [
"pytest >=7.1.3,<8.0.0",
"coverage[toml] >= 6.5.0,< 8.0",
"mypy ==0.982",
"ruff ==0.0.138",
"black == 23.1.0",
"isort >=5.0.6,<6.0.0",
"httpx >=0.23.0,<0.24.0",
"email_validator >=1.1.1,<2.0.0",
# TODO: once removing databases from tutorial, upgrade SQLAlchemy
# probably when including SQLModel
"sqlalchemy >=1.3.18,<1.4.43",
"peewee >=3.13.3,<4.0.0",
"databases[sqlite] >=0.3.2,<0.7.0",
"orjson >=3.2.1,<4.0.0",
"ujson >=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0",
"python-multipart >=0.0.5,<0.0.7",
"flask >=1.1.2,<3.0.0",
"anyio[trio] >=3.2.1,<4.0.0",
"python-jose[cryptography] >=3.3.0,<4.0.0",
"pyyaml >=5.3.1,<7.0.0",
"passlib[bcrypt] >=1.7.2,<2.0.0",

# types
"types-ujson ==5.7.0.1",
"types-orjson ==3.6.2",
]
doc = [
"mkdocs >=1.1.2,<2.0.0",
"mkdocs-material >=8.1.4,<9.0.0",
"mdx-include >=1.4.1,<2.0.0",
"mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0",
"typer-cli >=0.0.13,<0.0.14",
"typer[all] >=0.6.1,<0.8.0",
"pyyaml >=5.3.1,<7.0.0",
]
dev = [
"ruff ==0.0.138",
"uvicorn[standard] >=0.12.0,<0.21.0",
"pre-commit >=2.17.0,<3.0.0",
]
all = [
"httpx >=0.23.0",
"jinja2 >=2.11.2",
Expand Down
8 changes: 8 additions & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-e .
mkdocs >=1.1.2,<2.0.0
mkdocs-material >=8.1.4,<9.0.0
mdx-include >=1.4.1,<2.0.0
mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
typer-cli >=0.0.13,<0.0.14
typer[all] >=0.6.1,<0.8.0
pyyaml >=5.3.1,<7.0.0
26 changes: 26 additions & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-e .
pytest >=7.1.3,<8.0.0
coverage[toml] >= 6.5.0,< 8.0
mypy ==0.982
ruff ==0.0.138
black == 23.1.0
isort >=5.0.6,<6.0.0
httpx >=0.23.0,<0.24.0
email_validator >=1.1.1,<2.0.0
# TODO: once removing databases from tutorial, upgrade SQLAlchemy
# probably when including SQLModel
sqlalchemy >=1.3.18,<1.4.43
peewee >=3.13.3,<4.0.0
databases[sqlite] >=0.3.2,<0.7.0
orjson >=3.2.1,<4.0.0
ujson >=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0
python-multipart >=0.0.5,<0.0.7
flask >=1.1.2,<3.0.0
anyio[trio] >=3.2.1,<4.0.0
python-jose[cryptography] >=3.3.0,<4.0.0
pyyaml >=5.3.1,<7.0.0
passlib[bcrypt] >=1.7.2,<2.0.0

# types
types-ujson ==5.7.0.1
types-orjson ==3.6.2
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-e .[all]
-r requirements-tests.txt
-r requirements-docs.txt
ruff ==0.0.138
uvicorn[standard] >=0.12.0,<0.21.0
pre-commit >=2.17.0,<3.0.0
2 changes: 2 additions & 0 deletions scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
set -e
set -x

# Check README.md is up to date
python ./scripts/docs.py verify-readme
python ./scripts/docs.py build-all
2 changes: 0 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
set -e
set -x

# Check README.md is up to date
python ./scripts/docs.py verify-readme
export PYTHONPATH=./docs_src
coverage run -m pytest tests ${@}

0 comments on commit 6595658

Please sign in to comment.