mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-12 13:36:41 +00:00
🔧 Update package metadata, drop support for Python 3.6, move build internals from Flit to Hatch (#5240)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
b2aa3593be
commit
4267bd1f4f
28 changed files with 82 additions and 223 deletions
7
.github/workflows/build-docs.yml
vendored
7
.github/workflows/build-docs.yml
vendored
|
|
@ -23,17 +23,14 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
path: ${{ env.pythonLocation }}
|
||||||
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v03
|
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v03
|
||||||
- name: Install Flit
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
run: python3.7 -m pip install flit
|
|
||||||
- name: Install docs extras
|
- name: Install docs extras
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: python3.7 -m flit install --deps production --extras doc
|
run: pip install .[doc]
|
||||||
- name: Install Material for MkDocs Insiders
|
- 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'
|
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
|
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
|
||||||
- name: Build Docs
|
- name: Build Docs
|
||||||
run: python3.7 ./scripts/docs.py build-all
|
run: python ./scripts/docs.py build-all
|
||||||
- name: Zip docs
|
- name: Zip docs
|
||||||
run: bash ./scripts/zip-docs.sh
|
run: bash ./scripts/zip-docs.sh
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
|
|
||||||
18
.github/workflows/publish.yml
vendored
18
.github/workflows/publish.yml
vendored
|
|
@ -17,23 +17,21 @@ jobs:
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.6"
|
python-version: "3.7"
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
path: ${{ env.pythonLocation }}
|
||||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
|
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
|
||||||
- name: Install Flit
|
- name: Install build dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: pip install flit
|
run: pip install build
|
||||||
- name: Install Dependencies
|
- name: Build distribution
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
run: python -m build
|
||||||
run: flit install --symlink
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
env:
|
uses: pypa/gh-action-pypi-publish@v1.5.1
|
||||||
FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
|
with:
|
||||||
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
run: bash scripts/publish.sh
|
|
||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
env:
|
env:
|
||||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||||
|
|
|
||||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
|
|
@ -12,7 +12,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
|
python-version: ["3.7", "3.8", "3.9", "3.10"]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -26,14 +26,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
path: ${{ env.pythonLocation }}
|
||||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v02
|
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v02
|
||||||
- name: Install Flit
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
run: pip install flit
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: flit install --symlink
|
run: pip install -e .[all,dev,doc,test]
|
||||||
- name: Lint
|
- name: Lint
|
||||||
if: ${{ matrix.python-version != '3.6' }}
|
|
||||||
run: bash scripts/lint.sh
|
run: bash scripts/lint.sh
|
||||||
- name: Test
|
- name: Test
|
||||||
run: bash scripts/test.sh
|
run: bash scripts/test.sh
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
|
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
|
||||||
|
|
||||||
The key features are:
|
The key features are:
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ You do that with standard modern Python types.
|
||||||
|
|
||||||
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
|
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
|
||||||
|
|
||||||
Just standard **Python 3.6+**.
|
Just standard **Python 3.7+**.
|
||||||
|
|
||||||
For example, for an `int`:
|
For example, for an `int`:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,48 +99,16 @@ $ python -m pip install --upgrade pip
|
||||||
!!! tip
|
!!! tip
|
||||||
Every time you install a new package with `pip` under that environment, activate the environment again.
|
Every time you install a new package with `pip` under that environment, activate the environment again.
|
||||||
|
|
||||||
This makes sure that if you use a terminal program installed by that package (like `flit`), you use the one from your local environment and not any other that could be installed globally.
|
This makes sure that if you use a terminal program installed by that package, you use the one from your local environment and not any other that could be installed globally.
|
||||||
|
|
||||||
### Flit
|
### pip
|
||||||
|
|
||||||
**FastAPI** uses <a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> to build, package and publish the project.
|
After activating the environment as described above:
|
||||||
|
|
||||||
After activating the environment as described above, install `flit`:
|
|
||||||
|
|
||||||
<div class="termy">
|
<div class="termy">
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ pip install flit
|
$ pip install -e .[dev,doc,test]
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).
|
|
||||||
|
|
||||||
And now use `flit` to install the development dependencies:
|
|
||||||
|
|
||||||
=== "Linux, macOS"
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --symlink
|
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
=== "Windows"
|
|
||||||
|
|
||||||
If you are on Windows, use `--pth-file` instead of `--symlink`:
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --pth-file
|
|
||||||
|
|
||||||
---> 100%
|
---> 100%
|
||||||
```
|
```
|
||||||
|
|
@ -153,7 +121,7 @@ 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.
|
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 `--symlink` (or `--pth-file` on Windows), 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, as it is installed with `-e`, 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.
|
That way, you don't have to "install" your local version to be able to test every change.
|
||||||
|
|
||||||
|
|
@ -171,7 +139,7 @@ $ bash scripts/format.sh
|
||||||
|
|
||||||
It will also auto-sort all your imports.
|
It will also auto-sort all your imports.
|
||||||
|
|
||||||
For it to sort them correctly, you need to have FastAPI installed locally in your environment, with the command in the section above using `--symlink` (or `--pth-file` on Windows).
|
For it to sort them correctly, you need to have FastAPI installed locally in your environment, with the command in the section above using `-e`.
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
|
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
|
||||||
|
|
||||||
The key features are:
|
The key features are:
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ You do that with standard modern Python types.
|
||||||
|
|
||||||
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
|
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
|
||||||
|
|
||||||
Just standard **Python 3.6+**.
|
Just standard **Python 3.7+**.
|
||||||
|
|
||||||
For example, for an `int`:
|
For example, for an `int`:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ Si estás construyendo un app de <abbr title="Interfaz de línea de comandos en
|
||||||
|
|
||||||
## Requisitos
|
## Requisitos
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI está sobre los hombros de gigantes:
|
FastAPI está sobre los hombros de gigantes:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,49 +88,16 @@ $ python -m venv env
|
||||||
!!! tip "豆知識"
|
!!! tip "豆知識"
|
||||||
この環境で`pip`を使って新しいパッケージをインストールするたびに、仮想環境を再度有効化します。
|
この環境で`pip`を使って新しいパッケージをインストールするたびに、仮想環境を再度有効化します。
|
||||||
|
|
||||||
これにより、そのパッケージによってインストールされたターミナルのプログラム (`flit`など) を使用する場合、ローカル環境のものを使用し、グローバルにインストールされたものは使用されなくなります。
|
これにより、そのパッケージによってインストールされたターミナルのプログラム を使用する場合、ローカル環境のものを使用し、グローバルにインストールされたものは使用されなくなります。
|
||||||
|
|
||||||
### Flit
|
### pip
|
||||||
|
|
||||||
**FastAPI**は<a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> を使って、ビルド、パッケージ化、公開します。
|
上記のように環境を有効化した後:
|
||||||
|
|
||||||
上記のように環境を有効化した後、`flit`をインストールします:
|
|
||||||
|
|
||||||
<div class="termy">
|
<div class="termy">
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ pip install flit
|
$ pip install -e .[dev,doc,test]
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
次に、環境を再び有効化して、インストールしたばかりの`flit` (グローバルではない) を使用していることを確認します。
|
|
||||||
|
|
||||||
そして、`flit`を使用して開発のための依存関係をインストールします:
|
|
||||||
|
|
||||||
=== "Linux, macOS"
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --symlink
|
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
=== "Windows"
|
|
||||||
|
|
||||||
Windowsユーザーは、`--symlink`のかわりに`--pth-file`を使用します:
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --pth-file
|
|
||||||
|
|
||||||
---> 100%
|
---> 100%
|
||||||
```
|
```
|
||||||
|
|
@ -143,7 +110,7 @@ $ pip install flit
|
||||||
|
|
||||||
FastAPIをインポートして使用するPythonファイルを作成し、ローカル環境で実行すると、ローカルのFastAPIソースコードが使用されます。
|
FastAPIをインポートして使用するPythonファイルを作成し、ローカル環境で実行すると、ローカルのFastAPIソースコードが使用されます。
|
||||||
|
|
||||||
そして、`--symlink` (Windowsでは` --pth-file`) でインストールされているローカルのFastAPIソースコードを更新した場合、そのPythonファイルを再度実行すると、更新したばかりの新しいバージョンのFastAPIが使用されます。
|
そして、`-e` でインストールされているローカルのFastAPIソースコードを更新した場合、そのPythonファイルを再度実行すると、更新したばかりの新しいバージョンのFastAPIが使用されます。
|
||||||
|
|
||||||
これにより、ローカルバージョンを「インストール」しなくても、すべての変更をテストできます。
|
これにより、ローカルバージョンを「インストール」しなくても、すべての変更をテストできます。
|
||||||
|
|
||||||
|
|
@ -161,7 +128,7 @@ $ bash scripts/format.sh
|
||||||
|
|
||||||
また、すべてのインポートを自動でソートします。
|
また、すべてのインポートを自動でソートします。
|
||||||
|
|
||||||
正しく並べ替えるには、上記セクションのコマンドで `--symlink` (Windowsの場合は` --pth-file`) を使い、FastAPIをローカル環境にインストールしている必要があります。
|
正しく並べ替えるには、上記セクションのコマンドで `-e` を使い、FastAPIをローカル環境にインストールしている必要があります。
|
||||||
|
|
||||||
### インポートの整形
|
### インポートの整形
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ FastAPI は、Pythonの標準である型ヒントに基づいてPython 3.6 以
|
||||||
|
|
||||||
## 必要条件
|
## 必要条件
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI は巨人の肩の上に立っています。
|
FastAPI は巨人の肩の上に立っています。
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ FastAPI는 현대적이고, 빠르며(고성능), 파이썬 표준 타입 힌트
|
||||||
|
|
||||||
## 요구사항
|
## 요구사항
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI는 거인들의 어깨 위에 서 있습니다:
|
FastAPI는 거인들의 어깨 위에 서 있습니다:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ Jeżeli tworzysz aplikacje <abbr title="aplikacja z interfejsem konsolowym">CLI<
|
||||||
|
|
||||||
## Wymagania
|
## Wymagania
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI oparty jest na:
|
FastAPI oparty jest na:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,48 +89,16 @@ Se ele exibir o binário `pip` em `env/bin/pip` então funcionou. 🎉
|
||||||
!!! tip
|
!!! tip
|
||||||
Toda vez que você instalar um novo pacote com `pip` nesse ambiente, ative o ambiente novamente.
|
Toda vez que você instalar um novo pacote com `pip` nesse ambiente, ative o ambiente novamente.
|
||||||
|
|
||||||
Isso garante que se você usar um programa instalado por aquele pacote (como `flit`), você utilizará aquele de seu ambiente local e não outro que possa estar instalado globalmente.
|
Isso garante que se você usar um programa instalado por aquele pacote, você utilizará aquele de seu ambiente local e não outro que possa estar instalado globalmente.
|
||||||
|
|
||||||
### Flit
|
### pip
|
||||||
|
|
||||||
**FastAPI** utiliza <a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> para construir, empacotar e publicar o projeto.
|
Após ativar o ambiente como descrito acima:
|
||||||
|
|
||||||
Após ativar o ambiente como descrito acima, instale o `flit`:
|
|
||||||
|
|
||||||
<div class="termy">
|
<div class="termy">
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ pip install flit
|
$ pip install -e .[dev,doc,test]
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
Ative novamente o ambiente para ter certeza que você esteja utilizando o `flit` que você acabou de instalar (e não um global).
|
|
||||||
|
|
||||||
E agora use `flit` para instalar as dependências de desenvolvimento:
|
|
||||||
|
|
||||||
=== "Linux, macOS"
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --symlink
|
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
=== "Windows"
|
|
||||||
|
|
||||||
Se você está no Windows, use `--pth-file` ao invés de `--symlink`:
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --pth-file
|
|
||||||
|
|
||||||
---> 100%
|
---> 100%
|
||||||
```
|
```
|
||||||
|
|
@ -143,7 +111,7 @@ Isso irá instalar todas as dependências e seu FastAPI local em seu ambiente lo
|
||||||
|
|
||||||
Se você cria um arquivo Python que importa e usa FastAPI, e roda com Python de seu ambiente local, ele irá utilizar o código fonte de seu FastAPI local.
|
Se você cria um arquivo Python que importa e usa FastAPI, e roda com Python de seu ambiente local, ele irá utilizar o código fonte de seu FastAPI local.
|
||||||
|
|
||||||
E se você atualizar o código fonte do FastAPI local, como ele é instalado com `--symlink` (ou `--pth-file` no Windows), quando você rodar aquele arquivo Python novamente, ele irá utilizar a nova versão do FastAPI que você acabou de editar.
|
E se você atualizar o código fonte do FastAPI local, como ele é instalado com `-e`, quando você rodar aquele arquivo Python novamente, ele irá utilizar a nova versão do FastAPI que você acabou de editar.
|
||||||
|
|
||||||
Desse modo, você não tem que "instalar" sua versão local para ser capaz de testar cada mudança.
|
Desse modo, você não tem que "instalar" sua versão local para ser capaz de testar cada mudança.
|
||||||
|
|
||||||
|
|
@ -161,7 +129,7 @@ $ bash scripts/format.sh
|
||||||
|
|
||||||
Ele irá organizar também todos os seus imports.
|
Ele irá organizar também todos os seus imports.
|
||||||
|
|
||||||
Para que ele organize os imports corretamente, você precisa ter o FastAPI instalado localmente em seu ambiente, com o comando na seção acima usando `--symlink` (ou `--pth-file` no Windows).
|
Para que ele organize os imports corretamente, você precisa ter o FastAPI instalado localmente em seu ambiente, com o comando na seção acima usando `-e`.
|
||||||
|
|
||||||
### Formato dos imports
|
### Formato dos imports
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ Se você estiver construindo uma aplicação <abbr title="Command Line Interface
|
||||||
|
|
||||||
## Requisitos
|
## Requisitos
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI está nos ombros de gigantes:
|
FastAPI está nos ombros de gigantes:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ FastAPI — это современный, быстрый (высокопрои
|
||||||
|
|
||||||
## Зависимости
|
## Зависимости
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI стоит на плечах гигантов:
|
FastAPI стоит на плечах гигантов:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ Eğer API yerine <abbr title="Command Line Interface">komut satırı uygulaması
|
||||||
|
|
||||||
## Gereksinimler
|
## Gereksinimler
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI iki devin omuzları üstünde duruyor:
|
FastAPI iki devin omuzları üstünde duruyor:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Python 3.6+
|
Python 3.7+
|
||||||
|
|
||||||
FastAPI stands on the shoulders of giants:
|
FastAPI stands on the shoulders of giants:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,48 +88,16 @@ $ python -m venv env
|
||||||
!!! tip
|
!!! tip
|
||||||
每一次你在该环境下使用 `pip` 安装了新软件包时,请再次激活该环境。
|
每一次你在该环境下使用 `pip` 安装了新软件包时,请再次激活该环境。
|
||||||
|
|
||||||
这样可以确保你在使用由该软件包安装的终端程序(如 `flit`)时使用的是当前虚拟环境中的程序,而不是其他的可能是全局安装的程序。
|
这样可以确保你在使用由该软件包安装的终端程序时使用的是当前虚拟环境中的程序,而不是其他的可能是全局安装的程序。
|
||||||
|
|
||||||
### Flit
|
### pip
|
||||||
|
|
||||||
**FastAPI** 使用 <a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> 来构建、打包和发布项目。
|
如上所述激活环境后:
|
||||||
|
|
||||||
如上所述激活环境后,安装 `flit`:
|
|
||||||
|
|
||||||
<div class="termy">
|
<div class="termy">
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ pip install flit
|
$ pip install -e .[dev,doc,test]
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
现在重新激活环境,以确保你正在使用的是刚刚安装的 `flit`(而不是全局环境的)。
|
|
||||||
|
|
||||||
然后使用 `flit` 来安装开发依赖:
|
|
||||||
|
|
||||||
=== "Linux, macOS"
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --symlink
|
|
||||||
|
|
||||||
---> 100%
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
=== "Windows"
|
|
||||||
|
|
||||||
If you are on Windows, use `--pth-file` instead of `--symlink`:
|
|
||||||
|
|
||||||
<div class="termy">
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ flit install --deps develop --pth-file
|
|
||||||
|
|
||||||
---> 100%
|
---> 100%
|
||||||
```
|
```
|
||||||
|
|
@ -142,7 +110,7 @@ $ pip install flit
|
||||||
|
|
||||||
如果你创建一个导入并使用 FastAPI 的 Python 文件,然后使用虚拟环境中的 Python 运行它,它将使用你本地的 FastAPI 源码。
|
如果你创建一个导入并使用 FastAPI 的 Python 文件,然后使用虚拟环境中的 Python 运行它,它将使用你本地的 FastAPI 源码。
|
||||||
|
|
||||||
并且如果你更改该本地 FastAPI 的源码,由于它是通过 `--symlink` (或 Windows 上的 `--pth-file`)安装的,当你再次运行那个 Python 文件,它将使用你刚刚编辑过的最新版本的 FastAPI。
|
并且如果你更改该本地 FastAPI 的源码,由于它是通过 `-e` 安装的,当你再次运行那个 Python 文件,它将使用你刚刚编辑过的最新版本的 FastAPI。
|
||||||
|
|
||||||
这样,你不必再去重新"安装"你的本地版本即可测试所有更改。
|
这样,你不必再去重新"安装"你的本地版本即可测试所有更改。
|
||||||
|
|
||||||
|
|
@ -160,7 +128,7 @@ $ bash scripts/format.sh
|
||||||
|
|
||||||
它还会自动对所有导入代码进行整理。
|
它还会自动对所有导入代码进行整理。
|
||||||
|
|
||||||
为了使整理正确进行,你需要在当前环境中安装本地的 FastAPI,即在运行上述段落中的命令时添加 `--symlink`(或 Windows 上的 `--pth-file`)。
|
为了使整理正确进行,你需要在当前环境中安装本地的 FastAPI,即在运行上述段落中的命令时添加 `-e`。
|
||||||
|
|
||||||
### 格式化导入
|
### 格式化导入
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import sys
|
from contextlib import AsyncExitStack as AsyncExitStack # noqa
|
||||||
|
from contextlib import asynccontextmanager as asynccontextmanager
|
||||||
from typing import AsyncGenerator, ContextManager, TypeVar
|
from typing import AsyncGenerator, ContextManager, TypeVar
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
|
|
@ -9,14 +10,6 @@ from starlette.concurrency import ( # noqa
|
||||||
run_until_first_complete as run_until_first_complete,
|
run_until_first_complete as run_until_first_complete,
|
||||||
)
|
)
|
||||||
|
|
||||||
if sys.version_info >= (3, 7):
|
|
||||||
from contextlib import AsyncExitStack as AsyncExitStack
|
|
||||||
from contextlib import asynccontextmanager as asynccontextmanager
|
|
||||||
else:
|
|
||||||
from contextlib2 import AsyncExitStack as AsyncExitStack # noqa
|
|
||||||
from contextlib2 import asynccontextmanager as asynccontextmanager # noqa
|
|
||||||
|
|
||||||
|
|
||||||
_T = TypeVar("_T")
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from typing import (
|
||||||
Callable,
|
Callable,
|
||||||
Coroutine,
|
Coroutine,
|
||||||
Dict,
|
Dict,
|
||||||
|
ForwardRef,
|
||||||
List,
|
List,
|
||||||
Mapping,
|
Mapping,
|
||||||
Optional,
|
Optional,
|
||||||
|
|
@ -47,7 +48,7 @@ from pydantic.fields import (
|
||||||
Undefined,
|
Undefined,
|
||||||
)
|
)
|
||||||
from pydantic.schema import get_annotation_from_field_info
|
from pydantic.schema import get_annotation_from_field_info
|
||||||
from pydantic.typing import ForwardRef, evaluate_forwardref
|
from pydantic.typing import evaluate_forwardref
|
||||||
from pydantic.utils import lenient_issubclass
|
from pydantic.utils import lenient_issubclass
|
||||||
from starlette.background import BackgroundTasks
|
from starlette.background import BackgroundTasks
|
||||||
from starlette.concurrency import run_in_threadpool
|
from starlette.concurrency import run_in_threadpool
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ def jsonable_encoder(
|
||||||
if custom_encoder:
|
if custom_encoder:
|
||||||
encoder.update(custom_encoder)
|
encoder.update(custom_encoder)
|
||||||
obj_dict = obj.dict(
|
obj_dict = obj.dict(
|
||||||
include=include, # type: ignore # in Pydantic
|
include=include,
|
||||||
exclude=exclude, # type: ignore # in Pydantic
|
exclude=exclude,
|
||||||
by_alias=by_alias,
|
by_alias=by_alias,
|
||||||
exclude_unset=exclude_unset,
|
exclude_unset=exclude_unset,
|
||||||
exclude_none=exclude_none,
|
exclude_none=exclude_none,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["flit"]
|
requires = ["hatchling"]
|
||||||
build-backend = "flit.buildapi"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[tool.flit.metadata]
|
[project]
|
||||||
module = "fastapi"
|
name = "fastapi"
|
||||||
author = "Sebastián Ramírez"
|
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
|
||||||
author-email = "tiangolo@gmail.com"
|
readme = "README.md"
|
||||||
home-page = "https://github.com/tiangolo/fastapi"
|
requires-python = ">=3.7"
|
||||||
|
license = "MIT"
|
||||||
|
authors = [
|
||||||
|
{ name = "Sebastián Ramírez", email = "tiangolo@gmail.com" },
|
||||||
|
]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Intended Audience :: Information Technology",
|
"Intended Audience :: Information Technology",
|
||||||
"Intended Audience :: System Administrators",
|
"Intended Audience :: System Administrators",
|
||||||
|
|
@ -26,7 +30,6 @@ classifiers = [
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
"Programming Language :: Python :: 3.6",
|
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.7",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
|
|
@ -34,17 +37,17 @@ classifiers = [
|
||||||
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
||||||
"Topic :: Internet :: WWW/HTTP",
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
]
|
]
|
||||||
requires = [
|
dependencies = [
|
||||||
"starlette==0.19.1",
|
"starlette==0.19.1",
|
||||||
"pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0",
|
"pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0",
|
||||||
]
|
]
|
||||||
description-file = "README.md"
|
dynamic = ["version"]
|
||||||
requires-python = ">=3.6.1"
|
|
||||||
|
|
||||||
[tool.flit.metadata.urls]
|
[project.urls]
|
||||||
|
Homepage = "https://github.com/tiangolo/fastapi"
|
||||||
Documentation = "https://fastapi.tiangolo.com/"
|
Documentation = "https://fastapi.tiangolo.com/"
|
||||||
|
|
||||||
[tool.flit.metadata.requires-extra]
|
[project.optional-dependencies]
|
||||||
test = [
|
test = [
|
||||||
"pytest >=6.2.4,<7.0.0",
|
"pytest >=6.2.4,<7.0.0",
|
||||||
"pytest-cov >=2.12.0,<4.0.0",
|
"pytest-cov >=2.12.0,<4.0.0",
|
||||||
|
|
@ -67,7 +70,6 @@ test = [
|
||||||
# types
|
# types
|
||||||
"types-ujson ==4.2.1",
|
"types-ujson ==4.2.1",
|
||||||
"types-orjson ==3.6.2",
|
"types-orjson ==3.6.2",
|
||||||
"types-dataclasses ==0.6.5; python_version<'3.7'",
|
|
||||||
]
|
]
|
||||||
doc = [
|
doc = [
|
||||||
"mkdocs >=1.1.2,<2.0.0",
|
"mkdocs >=1.1.2,<2.0.0",
|
||||||
|
|
@ -99,6 +101,9 @@ all = [
|
||||||
"uvicorn[standard] >=0.12.0,<0.18.0",
|
"uvicorn[standard] >=0.12.0,<0.18.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tool.hatch.version]
|
||||||
|
path = "fastapi/__init__.py"
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
profile = "black"
|
profile = "black"
|
||||||
known_third_party = ["fastapi", "pydantic", "starlette"]
|
known_third_party = ["fastapi", "pydantic", "starlette"]
|
||||||
|
|
@ -128,6 +133,4 @@ filterwarnings = [
|
||||||
# TODO: needed by asyncio in Python 3.9.7 https://bugs.python.org/issue45097, try to remove on 3.9.8
|
# TODO: needed by asyncio in Python 3.9.7 https://bugs.python.org/issue45097, try to remove on 3.9.8
|
||||||
'ignore:The loop argument is deprecated since Python 3\.8, and scheduled for removal in Python 3\.10:DeprecationWarning:asyncio',
|
'ignore:The loop argument is deprecated since Python 3\.8, and scheduled for removal in Python 3\.10:DeprecationWarning:asyncio',
|
||||||
'ignore:starlette.middleware.wsgi is deprecated and will be removed in a future release\..*:DeprecationWarning:starlette',
|
'ignore:starlette.middleware.wsgi is deprecated and will be removed in a future release\..*:DeprecationWarning:starlette',
|
||||||
# TODO: remove after dropping support for Python 3.6
|
|
||||||
'ignore:Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.:UserWarning:jose',
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue