mirror of https://github.com/tiangolo/fastapi.git
🔧 Add configs and setup for `fastapi-slim` including optional extras `fastapi-slim[standard]`, and `fastapi` including by default the same `standard` extras (#11503)
This commit is contained in:
parent
32be95dd86
commit
ea1f2190d3
|
|
@ -12,6 +12,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
package:
|
package:
|
||||||
- fastapi
|
- fastapi
|
||||||
|
- fastapi-slim
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,11 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
test-redistribute:
|
test-redistribute:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
package:
|
||||||
|
- fastapi
|
||||||
|
- fastapi-slim
|
||||||
steps:
|
steps:
|
||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
env:
|
env:
|
||||||
|
|
@ -22,12 +27,11 @@ jobs:
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.10"
|
||||||
# Issue ref: https://github.com/actions/setup-python/issues/436
|
|
||||||
# cache: "pip"
|
|
||||||
# cache-dependency-path: pyproject.toml
|
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: pip install build
|
run: pip install build
|
||||||
- name: Build source distribution
|
- name: Build source distribution
|
||||||
|
env:
|
||||||
|
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
|
||||||
run: python -m build --sdist
|
run: python -m build --sdist
|
||||||
- name: Decompress source distribution
|
- name: Decompress source distribution
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -35,16 +39,16 @@ jobs:
|
||||||
tar xvf fastapi*.tar.gz
|
tar xvf fastapi*.tar.gz
|
||||||
- name: Install test dependencies
|
- name: Install test dependencies
|
||||||
run: |
|
run: |
|
||||||
cd dist/fastapi-*/
|
cd dist/fastapi*/
|
||||||
pip install -r requirements-tests.txt
|
pip install -r requirements-tests.txt
|
||||||
- name: Run source distribution tests
|
- name: Run source distribution tests
|
||||||
run: |
|
run: |
|
||||||
cd dist/fastapi-*/
|
cd dist/fastapi*/
|
||||||
bash scripts/test.sh
|
bash scripts/test.sh
|
||||||
- name: Build wheel distribution
|
- name: Build wheel distribution
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
pip wheel --no-deps fastapi-*.tar.gz
|
pip wheel --no-deps fastapi*.tar.gz
|
||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
env:
|
env:
|
||||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||||
|
|
||||||
__version__ = "0.110.3"
|
__version__ = "0.111.0.dev1"
|
||||||
|
|
||||||
from starlette import status as status
|
from starlette import status as status
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import os
|
||||||
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
from pdm.backend.hooks import Context
|
||||||
|
|
||||||
|
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "fastapi")
|
||||||
|
|
||||||
|
|
||||||
|
def pdm_build_initialize(context: Context) -> None:
|
||||||
|
metadata = context.config.metadata
|
||||||
|
# Get custom config for the current package, from the env var
|
||||||
|
config: Dict[str, Any] = context.config.data["tool"]["tiangolo"][
|
||||||
|
"_internal-slim-build"
|
||||||
|
]["packages"][TIANGOLO_BUILD_PACKAGE]
|
||||||
|
project_config: Dict[str, Any] = config["project"]
|
||||||
|
# Get main optional dependencies, extras
|
||||||
|
optional_dependencies: Dict[str, List[str]] = metadata.get(
|
||||||
|
"optional-dependencies", {}
|
||||||
|
)
|
||||||
|
# Get custom optional dependencies name to always include in this (non-slim) package
|
||||||
|
include_optional_dependencies: List[str] = config.get(
|
||||||
|
"include-optional-dependencies", []
|
||||||
|
)
|
||||||
|
# Override main [project] configs with custom configs for this package
|
||||||
|
for key, value in project_config.items():
|
||||||
|
metadata[key] = value
|
||||||
|
# Get custom build config for the current package
|
||||||
|
build_config: Dict[str, Any] = (
|
||||||
|
config.get("tool", {}).get("pdm", {}).get("build", {})
|
||||||
|
)
|
||||||
|
# Override PDM build config with custom build config for this package
|
||||||
|
for key, value in build_config.items():
|
||||||
|
context.config.build_config[key] = value
|
||||||
|
# Get main dependencies
|
||||||
|
dependencies: List[str] = metadata.get("dependencies", [])
|
||||||
|
# Add optional dependencies to the default dependencies for this (non-slim) package
|
||||||
|
for include_optional in include_optional_dependencies:
|
||||||
|
optional_dependencies_group = optional_dependencies.get(include_optional, [])
|
||||||
|
dependencies.extend(optional_dependencies_group)
|
||||||
|
|
@ -53,26 +53,27 @@ Repository = "https://github.com/tiangolo/fastapi"
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|
||||||
# standard = [
|
standard = [
|
||||||
# # For the test client
|
# For the test client
|
||||||
# "httpx >=0.23.0",
|
"httpx >=0.23.0",
|
||||||
# # For templates
|
# For templates
|
||||||
# "jinja2 >=2.11.2",
|
"jinja2 >=2.11.2",
|
||||||
# # For forms and file uploads
|
# For forms and file uploads
|
||||||
# "python-multipart >=0.0.7",
|
"python-multipart >=0.0.7",
|
||||||
# # For UJSONResponse
|
# For UJSONResponse
|
||||||
# "ujson >=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0",
|
"ujson >=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0",
|
||||||
# # For ORJSONResponse
|
# For ORJSONResponse
|
||||||
# "orjson >=3.2.1",
|
"orjson >=3.2.1",
|
||||||
# # To validate email fields
|
# To validate email fields
|
||||||
# "email_validator >=2.0.0",
|
"email_validator >=2.0.0",
|
||||||
# # Uvicorn with uvloop
|
# Uvicorn with uvloop
|
||||||
# "uvicorn[standard] >=0.12.0",
|
"uvicorn[standard] >=0.12.0",
|
||||||
# # Settings management
|
# TODO: this should be part of some pydantic optional extra dependencies
|
||||||
# "pydantic-settings >=2.0.0",
|
# # Settings management
|
||||||
# # Extra Pydantic data types
|
# "pydantic-settings >=2.0.0",
|
||||||
# "pydantic-extra-types >=2.0.0",
|
# # Extra Pydantic data types
|
||||||
# ]
|
# "pydantic-extra-types >=2.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
all = [
|
all = [
|
||||||
# # For the test client
|
# # For the test client
|
||||||
|
|
@ -113,6 +114,37 @@ source-includes = [
|
||||||
"docs/en/docs/img/favicon.png",
|
"docs/en/docs/img/favicon.png",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tool.tiangolo._internal-slim-build.packages.fastapi-slim.project]
|
||||||
|
name = "fastapi-slim"
|
||||||
|
|
||||||
|
[tool.tiangolo._internal-slim-build.packages.fastapi]
|
||||||
|
include-optional-dependencies = ["standard"]
|
||||||
|
|
||||||
|
[tool.tiangolo._internal-slim-build.packages.fastapi.project.optional-dependencies]
|
||||||
|
all = [
|
||||||
|
# # For the test client
|
||||||
|
"httpx >=0.23.0",
|
||||||
|
# For templates
|
||||||
|
"jinja2 >=2.11.2",
|
||||||
|
# For forms and file uploads
|
||||||
|
"python-multipart >=0.0.7",
|
||||||
|
# For Starlette's SessionMiddleware, not commonly used with FastAPI
|
||||||
|
"itsdangerous >=1.1.0",
|
||||||
|
# For Starlette's schema generation, would not be used with FastAPI
|
||||||
|
"pyyaml >=5.3.1",
|
||||||
|
# For UJSONResponse
|
||||||
|
"ujson >=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0",
|
||||||
|
# For ORJSONResponse
|
||||||
|
"orjson >=3.2.1",
|
||||||
|
# To validate email fields
|
||||||
|
"email_validator >=2.0.0",
|
||||||
|
# Uvicorn with uvloop
|
||||||
|
"uvicorn[standard] >=0.12.0",
|
||||||
|
# Settings management
|
||||||
|
"pydantic-settings >=2.0.0",
|
||||||
|
# Extra Pydantic data types
|
||||||
|
"pydantic-extra-types >=2.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
strict = true
|
strict = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue