Browse Source

⬆️ Migrate to uv (#14676)

pull/14525/head
Jonathan Ehwald 5 months ago
committed by GitHub
parent
commit
b4ba7f4652
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      .github/dependabot.yml
  2. 25
      .github/workflows/build-docs.yml
  3. 12
      .github/workflows/contributors.yml
  4. 16
      .github/workflows/deploy-docs.yml
  5. 12
      .github/workflows/label-approved.yml
  6. 12
      .github/workflows/notify-translations.yml
  7. 12
      .github/workflows/people.yml
  8. 7
      .github/workflows/pre-commit.yml
  9. 15
      .github/workflows/publish.yml
  10. 11
      .github/workflows/smokeshow.yml
  11. 12
      .github/workflows/sponsors.yml
  12. 4
      .github/workflows/test-redistribute.yml
  13. 26
      .github/workflows/test.yml
  14. 12
      .github/workflows/topic-repos.yml
  15. 23
      .github/workflows/translate.yml
  16. 3
      .gitignore
  17. 1
      .pre-commit-config.yaml
  18. 1
      .python-version
  19. 32
      docs/en/docs/contributing.md
  20. 65
      pyproject.toml
  21. 4
      requirements-docs-tests.txt
  22. 21
      requirements-docs.txt
  23. 6
      requirements-github-actions.txt
  24. 18
      requirements-tests.txt
  25. 3
      requirements-translations.txt
  26. 7
      requirements.txt
  27. 5339
      uv.lock

2
.github/dependabot.yml

@ -8,7 +8,7 @@ updates:
commit-message: commit-message:
prefix: prefix:
# Python # Python
- package-ecosystem: "pip" - package-ecosystem: "uv"
directory: "/" directory: "/"
schedule: schedule:
interval: "monthly" interval: "monthly"

25
.github/workflows/build-docs.yml

@ -8,9 +8,6 @@ on:
- opened - opened
- synchronize - synchronize
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
changes: changes:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -31,8 +28,8 @@ jobs:
- README.md - README.md
- docs/** - docs/**
- docs_src/** - docs_src/**
- requirements-docs.txt
- pyproject.toml - pyproject.toml
- uv.lock
- mkdocs.yml - mkdocs.yml
- mkdocs.env.yml - mkdocs.env.yml
- .github/workflows/build-docs.yml - .github/workflows/build-docs.yml
@ -49,21 +46,20 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install docs extras - name: Install docs extras
run: uv pip install -r requirements-docs.txt run: uv sync --locked --no-dev --group docs
- name: Export Language Codes - name: Export Language Codes
id: show-langs id: show-langs
run: | run: |
echo "langs=$(python ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT echo "langs=$(uv run ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT
build-docs: build-docs:
needs: needs:
@ -83,25 +79,24 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install docs extras - name: Install docs extras
run: uv pip install -r requirements-docs.txt run: uv sync --locked --no-dev --group docs
- name: Update Languages - name: Update Languages
run: python ./scripts/docs.py update-languages run: uv run ./scripts/docs.py update-languages
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:
key: mkdocs-cards-${{ matrix.lang }}-${{ github.ref }} key: mkdocs-cards-${{ matrix.lang }}-${{ github.ref }}
path: docs/${{ matrix.lang }}/.cache path: docs/${{ matrix.lang }}/.cache
- name: Build Docs - name: Build Docs
run: python ./scripts/docs.py build-lang ${{ matrix.lang }} run: uv run ./scripts/docs.py build-lang ${{ matrix.lang }}
- uses: actions/upload-artifact@v5 - uses: actions/upload-artifact@v5
with: with:
name: docs-site-${{ matrix.lang }} name: docs-site-${{ matrix.lang }}

12
.github/workflows/contributors.yml

@ -10,9 +10,6 @@ on:
required: false required: false
default: "false" default: "false"
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
job: job:
if: github.repository_owner == 'fastapi' if: github.repository_owner == 'fastapi'
@ -28,17 +25,16 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
# Allow debugging with tmate # Allow debugging with tmate
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@ -48,6 +44,6 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }} GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }}
- name: FastAPI People Contributors - name: FastAPI People Contributors
run: python ./scripts/contributors.py run: uv run ./scripts/contributors.py
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }} GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }}

16
.github/workflows/deploy-docs.yml

@ -12,9 +12,6 @@ permissions:
pull-requests: write pull-requests: write
statuses: write statuses: write
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
deploy-docs: deploy-docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -27,19 +24,18 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install GitHub Actions dependencies - name: Install GitHub Actions dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
- name: Deploy Docs Status Pending - name: Deploy Docs Status Pending
run: python ./scripts/deploy_docs_status.py run: uv run ./scripts/deploy_docs_status.py
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }} COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
@ -70,14 +66,14 @@ jobs:
command: pages deploy ./site --project-name=${{ env.PROJECT_NAME }} --branch=${{ env.BRANCH }} command: pages deploy ./site --project-name=${{ env.PROJECT_NAME }} --branch=${{ env.BRANCH }}
- name: Deploy Docs Status Error - name: Deploy Docs Status Error
if: failure() if: failure()
run: python ./scripts/deploy_docs_status.py run: uv run ./scripts/deploy_docs_status.py
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }} COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_ID: ${{ github.run_id }} RUN_ID: ${{ github.run_id }}
STATE: "error" STATE: "error"
- name: Comment Deploy - name: Comment Deploy
run: python ./scripts/deploy_docs_status.py run: uv run ./scripts/deploy_docs_status.py
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEPLOY_URL: ${{ steps.deploy.outputs.deployment-url }} DEPLOY_URL: ${{ steps.deploy.outputs.deployment-url }}

12
.github/workflows/label-approved.yml

@ -8,9 +8,6 @@ on:
permissions: permissions:
pull-requests: write pull-requests: write
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
label-approved: label-approved:
if: github.repository_owner == 'fastapi' if: github.repository_owner == 'fastapi'
@ -24,19 +21,18 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install GitHub Actions dependencies - name: Install GitHub Actions dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
- name: Label Approved - name: Label Approved
run: python ./scripts/label_approved.py run: uv run ./scripts/label_approved.py
env: env:
TOKEN: ${{ secrets.GITHUB_TOKEN }} TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG: > CONFIG: >

12
.github/workflows/notify-translations.yml

@ -15,9 +15,6 @@ on:
required: false required: false
default: 'false' default: 'false'
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
job: job:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -32,17 +29,16 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
# Allow debugging with tmate # Allow debugging with tmate
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@ -52,7 +48,7 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Translations - name: Notify Translations
run: python ./scripts/notify_translations.py run: uv run ./scripts/notify_translations.py
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMBER: ${{ github.event.inputs.number || null }} NUMBER: ${{ github.event.inputs.number || null }}

12
.github/workflows/people.yml

@ -10,9 +10,6 @@ on:
required: false required: false
default: "false" default: "false"
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
job: job:
if: github.repository_owner == 'fastapi' if: github.repository_owner == 'fastapi'
@ -28,17 +25,16 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
# Allow debugging with tmate # Allow debugging with tmate
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@ -48,7 +44,7 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_PEOPLE }} GITHUB_TOKEN: ${{ secrets.FASTAPI_PEOPLE }}
- name: FastAPI People Experts - name: FastAPI People Experts
run: python ./scripts/people.py run: uv run ./scripts/people.py
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_PEOPLE }} GITHUB_TOKEN: ${{ secrets.FASTAPI_PEOPLE }}
SLEEP_INTERVAL: ${{ vars.PEOPLE_SLEEP_INTERVAL }} SLEEP_INTERVAL: ${{ vars.PEOPLE_SLEEP_INTERVAL }}

7
.github/workflows/pre-commit.yml

@ -40,18 +40,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.14" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock uv.lock
- name: Install Dependencies - name: Install Dependencies
run: | run: uv sync --locked --extra all
uv venv
uv pip install -r requirements.txt
- name: Run prek - pre-commit - name: Run prek - pre-commit
id: precommit id: precommit
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure

15
.github/workflows/publish.yml

@ -15,6 +15,7 @@ jobs:
- fastapi-slim - fastapi-slim
permissions: permissions:
id-token: write id-token: write
contents: read
steps: steps:
- name: Dump GitHub context - name: Dump GitHub context
env: env:
@ -24,19 +25,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.10" python-version-file: ".python-version"
# Issue ref: https://github.com/actions/setup-python/issues/436 # Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip" # cache: "pip"
# cache-dependency-path: pyproject.toml # cache-dependency-path: pyproject.toml
- name: Install build dependencies - name: Install uv
run: pip install build uses: astral-sh/setup-uv@v7
- name: Build distribution - name: Build distribution
run: uv build
env: env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }} TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish - name: Publish
uses: pypa/[email protected] run: uv publish
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

11
.github/workflows/smokeshow.yml

@ -8,9 +8,6 @@ on:
permissions: permissions:
statuses: write statuses: write
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
smokeshow: smokeshow:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -23,14 +20,14 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions/setup-python@v6 - uses: actions/setup-python@v6
with: with:
python-version: '3.13' python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
- run: uv pip install -r requirements-github-actions.txt uv.lock
- run: uv sync --locked --no-dev --group github-actions
- uses: actions/download-artifact@v6 - uses: actions/download-artifact@v6
with: with:
name: coverage-html name: coverage-html
@ -41,7 +38,7 @@ jobs:
- name: Upload coverage to Smokeshow - name: Upload coverage to Smokeshow
run: | run: |
for i in 1 2 3 4 5; do for i in 1 2 3 4 5; do
if smokeshow upload htmlcov; then if uv run smokeshow upload htmlcov; then
echo "Smokeshow upload success!" echo "Smokeshow upload success!"
break break
fi fi

12
.github/workflows/sponsors.yml

@ -10,9 +10,6 @@ on:
required: false required: false
default: "false" default: "false"
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
job: job:
if: github.repository_owner == 'fastapi' if: github.repository_owner == 'fastapi'
@ -28,17 +25,16 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
# Allow debugging with tmate # Allow debugging with tmate
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@ -46,7 +42,7 @@ jobs:
with: with:
limit-access-to-actor: true limit-access-to-actor: true
- name: FastAPI People Sponsors - name: FastAPI People Sponsors
run: python ./scripts/sponsors.py run: uv run ./scripts/sponsors.py
env: env:
SPONSORS_TOKEN: ${{ secrets.SPONSORS_TOKEN }} SPONSORS_TOKEN: ${{ secrets.SPONSORS_TOKEN }}
PR_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }} PR_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }}

4
.github/workflows/test-redistribute.yml

@ -26,7 +26,7 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.10" python-version-file: ".python-version"
- name: Install build dependencies - name: Install build dependencies
run: pip install build run: pip install build
- name: Build source distribution - name: Build source distribution
@ -40,7 +40,7 @@ jobs:
- name: Install test dependencies - name: Install test dependencies
run: | run: |
cd dist/fastapi*/ cd dist/fastapi*/
pip install -r requirements-tests.txt pip install --group tests --editable .[all]
env: env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }} TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
- name: Run source distribution tests - name: Run source distribution tests

26
.github/workflows/test.yml

@ -13,7 +13,7 @@ on:
- cron: "0 0 * * 1" - cron: "0 0 * * 1"
env: env:
UV_SYSTEM_PYTHON: 1 UV_NO_SYNC: true
jobs: jobs:
test: test:
@ -44,6 +44,8 @@ jobs:
coverage: coverage coverage: coverage
fail-fast: false fail-fast: false
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env:
UV_PYTHON: ${{ matrix.python-version }}
steps: steps:
- name: Dump GitHub context - name: Dump GitHub context
env: env:
@ -57,17 +59,16 @@ jobs:
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-tests.txt run: uv sync --locked --no-dev --group tests --extra all
- run: mkdir coverage - run: mkdir coverage
- name: Test - name: Test
if: matrix.codspeed != 'codspeed' if: matrix.codspeed != 'codspeed'
run: bash scripts/test.sh run: uv run bash scripts/test.sh
env: env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
@ -79,7 +80,7 @@ jobs:
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
with: with:
mode: simulation mode: simulation
run: coverage run -m pytest tests/ --codspeed run: uv run coverage run -m pytest tests/ --codspeed
# Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow # Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow
- name: Store coverage files - name: Store coverage files
if: matrix.coverage == 'coverage' if: matrix.coverage == 'coverage'
@ -100,17 +101,16 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions/setup-python@v6 - uses: actions/setup-python@v6
with: with:
python-version: '3.11' python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-tests.txt run: uv sync --locked --no-dev --group tests --extra all
- name: Get coverage files - name: Get coverage files
uses: actions/download-artifact@v6 uses: actions/download-artifact@v6
with: with:
@ -118,15 +118,15 @@ jobs:
path: coverage path: coverage
merge-multiple: true merge-multiple: true
- run: ls -la coverage - run: ls -la coverage
- run: coverage combine coverage - run: uv run coverage combine coverage
- run: coverage html --title "Coverage for ${{ github.sha }}" - run: uv run coverage html --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML - name: Store coverage HTML
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
name: coverage-html name: coverage-html
path: htmlcov path: htmlcov
include-hidden-files: true include-hidden-files: true
- run: coverage report --fail-under=100 - run: uv run coverage report --fail-under=100
# https://github.com/marketplace/actions/alls-green#why # https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection check: # This job does nothing and is only used for the branch protection

12
.github/workflows/topic-repos.yml

@ -5,9 +5,6 @@ on:
- cron: "0 12 1 * *" - cron: "0 12 1 * *"
workflow_dispatch: workflow_dispatch:
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
topic-repos: topic-repos:
if: github.repository_owner == 'fastapi' if: github.repository_owner == 'fastapi'
@ -23,18 +20,17 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
version: "0.4.15"
enable-cache: true enable-cache: true
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install GitHub Actions dependencies - name: Install GitHub Actions dependencies
run: uv pip install -r requirements-github-actions.txt run: uv sync --locked --no-dev --group github-actions
- name: Update Topic Repos - name: Update Topic Repos
run: python ./scripts/topic_repos.py run: uv run ./scripts/topic_repos.py
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }} GITHUB_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }}

23
.github/workflows/translate.yml

@ -31,9 +31,6 @@ on:
required: false required: false
default: "" default: ""
env:
UV_SYSTEM_PYTHON: 1
jobs: jobs:
langs: langs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -45,20 +42,20 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt -r requirements-translations.txt run: uv sync --locked --no-dev --group github-actions --group translations
- name: Export Language Codes - name: Export Language Codes
id: show-langs id: show-langs
run: | run: |
echo "langs=$(python ./scripts/translate.py llm-translatable-json)" >> $GITHUB_OUTPUT echo "langs=$(uv run ./scripts/translate.py llm-translatable-json)" >> $GITHUB_OUTPUT
echo "commands=$(python ./scripts/translate.py commands-json)" >> $GITHUB_OUTPUT echo "commands=$(uv run ./scripts/translate.py commands-json)" >> $GITHUB_OUTPUT
env: env:
LANGUAGE: ${{ github.event.inputs.language }} LANGUAGE: ${{ github.event.inputs.language }}
COMMAND: ${{ github.event.inputs.command }} COMMAND: ${{ github.event.inputs.command }}
@ -84,15 +81,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: "3.11" python-version-file: ".python-version"
- name: Setup uv - name: Setup uv
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7
with: with:
cache-dependency-glob: | cache-dependency-glob: |
requirements**.txt
pyproject.toml pyproject.toml
uv.lock
- name: Install Dependencies - name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt -r requirements-translations.txt run: uv sync --locked --no-dev --group github-actions --group translations
# Allow debugging with tmate # Allow debugging with tmate
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@ -104,8 +101,8 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: FastAPI Translate - name: FastAPI Translate
run: | run: |
python ./scripts/translate.py ${{ matrix.command }} uv run ./scripts/translate.py ${{ matrix.command }}
python ./scripts/translate.py make-pr uv run ./scripts/translate.py make-pr
env: env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_TRANSLATIONS }} GITHUB_TOKEN: ${{ secrets.FASTAPI_TRANSLATIONS }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

3
.gitignore

@ -29,7 +29,4 @@ archive.zip
# macOS # macOS
.DS_Store .DS_Store
# Ignore while the setup still depends on requirements.txt files
uv.lock
.codspeed .codspeed

1
.pre-commit-config.yaml

@ -6,6 +6,7 @@ repos:
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
args: ['--maxkb=750'] args: ['--maxkb=750']
exclude: ^uv.lock$
- id: check-toml - id: check-toml
- id: check-yaml - id: check-yaml
args: args:

1
.python-version

@ -0,0 +1 @@
3.11

32
docs/en/docs/contributing.md

@ -6,44 +6,20 @@ First, you might want to see the basic ways to [help FastAPI and get help](help-
If you already cloned the <a href="https://github.com/fastapi/fastapi" class="external-link" target="_blank">fastapi repository</a> and you want to deep dive in the code, here are some guidelines to set up your environment. If you already cloned the <a href="https://github.com/fastapi/fastapi" class="external-link" target="_blank">fastapi repository</a> and you want to deep dive in the code, here are some guidelines to set up your environment.
### Virtual environment
Follow the instructions to create and activate a [virtual environment](virtual-environments.md){.internal-link target=_blank} for the internal code of `fastapi`.
### Install requirements ### Install requirements
After activating the environment, install the required packages: Create a virtual environment and install the required packages with <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a>:
//// tab | `pip`
<div class="termy">
```console
$ pip install -r requirements.txt
---> 100%
```
</div>
////
//// tab | `uv`
If you have <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a>:
<div class="termy"> <div class="termy">
```console ```console
$ uv pip install -r requirements.txt $ uv sync
---> 100% ---> 100%
``` ```
</div> </div>
////
It will install all the dependencies and your local FastAPI in your local environment. It will install all the dependencies and your local FastAPI in your local environment.
### Using your local FastAPI ### Using your local FastAPI
@ -56,9 +32,9 @@ That way, you don't have to "install" your local version to be able to test ever
/// note | Technical Details /// note | Technical Details
This only happens when you install using this included `requirements.txt` instead of running `pip install fastapi` directly. This only happens when you install using `uv sync` instead of running `pip install fastapi` directly.
That is because inside the `requirements.txt` file, the local version of FastAPI is marked to be installed in "editable" mode, with the `-e` option. That is because `uv sync` will install the local version of FastAPI in "editable" mode by default.
/// ///

65
pyproject.toml

@ -123,6 +123,68 @@ all = [
[project.scripts] [project.scripts]
fastapi = "fastapi.cli:main" fastapi = "fastapi.cli:main"
[dependency-groups]
dev = [
{ include-group = "tests" },
{ include-group = "docs" },
{ include-group = "translations" },
"playwright>=1.57.0",
"prek==0.2.22",
]
docs = [
{ include-group = "docs-tests" },
"black==25.1.0",
"cairosvg==2.8.2",
"griffe-typingdoc==0.3.0",
"griffe-warnings-deprecated==1.1.0",
"jieba==0.42.1",
"markdown-include-variants==0.0.8",
"mdx-include>=1.4.1,<2.0.0",
"mkdocs-macros-plugin==1.4.1",
"mkdocs-material==9.7.0",
"mkdocs-redirects>=1.2.1,<1.3.0",
"mkdocstrings[python]==0.30.1",
"pillow==11.3.0",
"python-slugify==8.0.4",
"pyyaml>=5.3.1,<7.0.0",
"typer==0.16.0",
]
docs-tests = [
"httpx>=0.23.0,<1.0.0",
"ruff==0.14.3",
]
github-actions = [
"httpx>=0.27.0,<1.0.0",
"pydantic>=2.5.3,<3.0.0",
"pydantic-settings>=2.1.0,<3.0.0",
"pygithub>=2.3.0,<3.0.0",
"pyyaml>=5.3.1,<7.0.0",
"smokeshow>=0.5.0",
]
tests = [
{ include-group = "docs-tests" },
"anyio[trio]>=3.2.1,<5.0.0",
"coverage[toml]>=6.5.0,<8.0",
"dirty-equals==0.9.0",
"flask>=1.1.2,<4.0.0",
"inline-snapshot>=0.21.1",
"mypy==1.14.1",
"pwdlib[argon2]>=0.2.1",
"pyjwt==2.9.0",
"pytest>=7.1.3,<9.0.0",
"pytest-codspeed==4.2.0",
"pyyaml>=5.3.1,<7.0.0",
"sqlmodel==0.0.27",
"strawberry-graphql>=0.200.0,<1.0.0",
"types-orjson==3.6.2",
"types-ujson==5.10.0.20240515",
]
translations = [
"gitpython==3.1.45",
"pydantic-ai==0.4.10",
"pygithub==2.8.1",
]
[tool.pdm] [tool.pdm]
version = { source = "file", path = "fastapi/__init__.py" } version = { source = "file", path = "fastapi/__init__.py" }
distribution = true distribution = true
@ -131,11 +193,10 @@ distribution = true
source-includes = [ source-includes = [
"tests/", "tests/",
"docs_src/", "docs_src/",
"requirements*.txt",
"scripts/", "scripts/",
# For a test # For a test
"docs/en/docs/img/favicon.png", "docs/en/docs/img/favicon.png",
] ]
[tool.tiangolo._internal-slim-build.packages.fastapi-slim.project] [tool.tiangolo._internal-slim-build.packages.fastapi-slim.project]
name = "fastapi-slim" name = "fastapi-slim"

4
requirements-docs-tests.txt

@ -1,4 +0,0 @@
# For mkdocstrings and tests
httpx >=0.23.0,<1.0.0
# For linting and generating docs versions
ruff ==0.14.3

21
requirements-docs.txt

@ -1,21 +0,0 @@
-e .
-r requirements-docs-tests.txt
mkdocs-material==9.7.0
mdx-include >=1.4.1,<2.0.0
mkdocs-redirects>=1.2.1,<1.3.0
typer == 0.16.0
pyyaml >=5.3.1,<7.0.0
# For Material for MkDocs, Chinese search
jieba==0.42.1
# For image processing by Material for MkDocs
pillow==11.3.0
# For image processing by Material for MkDocs
cairosvg==2.8.2
mkdocstrings[python]==0.30.1
griffe-typingdoc==0.3.0
griffe-warnings-deprecated==1.1.0
# For griffe, it formats with black
black==25.1.0
mkdocs-macros-plugin==1.4.1
markdown-include-variants==0.0.8
python-slugify==8.0.4

6
requirements-github-actions.txt

@ -1,6 +0,0 @@
PyGithub>=2.3.0,<3.0.0
pydantic>=2.5.3,<3.0.0
pydantic-settings>=2.1.0,<3.0.0
httpx>=0.27.0,<1.0.0
pyyaml >=5.3.1,<7.0.0
smokeshow

18
requirements-tests.txt

@ -1,18 +0,0 @@
-e .[all]
-r requirements-docs-tests.txt
pytest >=7.1.3,<9.0.0
coverage[toml] >= 6.5.0,< 8.0
mypy ==1.14.1
dirty-equals ==0.9.0
sqlmodel==0.0.27
flask >=1.1.2,<4.0.0
strawberry-graphql >=0.200.0,< 1.0.0
anyio[trio] >=3.2.1,<5.0.0
PyJWT==2.9.0
pyyaml >=5.3.1,<7.0.0
pwdlib[argon2] >=0.2.1
inline-snapshot>=0.21.1
pytest-codspeed==4.2.0
# types
types-ujson ==5.10.0.20240515
types-orjson ==3.6.2

3
requirements-translations.txt

@ -1,3 +0,0 @@
pydantic-ai==0.4.10
GitPython==3.1.45
pygithub==2.8.1

7
requirements.txt

@ -1,7 +0,0 @@
-e .[all]
-r requirements-tests.txt
-r requirements-docs.txt
-r requirements-translations.txt
prek==0.2.22
# For generating screenshots
playwright

5339
uv.lock

File diff suppressed because it is too large
Loading…
Cancel
Save