summaryrefslogtreecommitdiff
path: root/dev-python/fastapi/fastapi-0.156.4.ebuild
blob: 1e1bf586041a6bc6410e12ab48cbabe19793dc90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Copyright 2025-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_USE_PEP517=pdm-backend
PYTHON_COMPAT=( python3_{13..14} )
#may be not stricly required
PYTHON_REQ_USE="threads(+)"

inherit distutils-r1 optfeature pypi

DESCRIPTION="High performance framework, easy to learn, fast to code, ready for production"
HOMEPAGE="
	https://fastapi.tiangolo.com/
	https://github.com/fastapi/fastapi/
	https://pypi.org/project/fastapi/
"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
	>=dev-python/annotated-doc-0.0.4[${PYTHON_USEDEP}]
	>=dev-python/opentelemetry-api-1.44.0[${PYTHON_USEDEP}]
	>=dev-python/pydantic-2.9.0[${PYTHON_USEDEP}]
	>=dev-python/starlette-0.46.0[${PYTHON_USEDEP}]
	>=dev-python/typing-extensions-4.8.0[${PYTHON_USEDEP}]
	>=dev-python/typing-inspection-0.4.2[${PYTHON_USEDEP}]
"

#FIXME: add missing deps
BDEPEND="
	test? (
		dev-python/a2wsgi[${PYTHON_USEDEP}]
		dev-python/dirty-equals[${PYTHON_USEDEP}]
		dev-python/flask[${PYTHON_USEDEP}]
		dev-python/httpx[${PYTHON_USEDEP}]
		dev-python/httpx2[${PYTHON_USEDEP}]
		dev-python/pydantic-settings[${PYTHON_USEDEP}]
		dev-python/python-multipart[${PYTHON_USEDEP}]
		dev-python/sqlalchemy[${PYTHON_USEDEP}]
		dev-python/typer[${PYTHON_USEDEP}]
	)
"

EPYTEST_PLUGINS=( anyio inline-snapshot pytest-timeout )
# workaround broken toml config
: ${EPYTEST_TIMEOUT:=30}
# the test suite is flaky as hell
EPYTEST_RERUNS=5
# 3k tests+, so use xdist to speed them up
EPYTEST_XDIST=1
distutils_enable_tests pytest

# There are some JSON response tests that will exercise orjson or ujson if they are available.
# These are properly skipped if the optional dependencies are not installed at the cost of a little spam.
python_test() {
	local EPYTEST_IGNORE=(
		# python/strawberry-graphql (in guru, test dep only)
		tests/test_tutorial/test_graphql/test_tutorial001.py
		# dev-python/sqlmodel (in guru, test dep only)
		tests/test_tutorial/test_sql_databases/test_tutorial001.py
		tests/test_tutorial/test_sql_databases/test_tutorial002.py
		# dev-python/fastapi-cli (missing, test and optfeature)
		tests/test_fastapi_cli.py
		# dev-python/pwdlib (in guru, test dep only)
		tests/test_tutorial/test_security/test_tutorial004.py
		tests/test_tutorial/test_security/test_tutorial005.py
		# Wants dev-python/multipart _just_ to complain that it's not the right multipart lib.
		tests/test_multipart_installation.py
		# scripts/tests use CliRunner.isolated_filesystem() removed in recent typer
		scripts/tests
	)
	local EPYTEST_DESELECT=(
		# Requires investigation - missing ./image.png test file (?)
		tests/test_tutorial/test_additional_responses/test_tutorial004.py::test_path_operation_img
		# Broken by brotli being available, also fragile to random ordering
		tests/test_tutorial/test_header_param_models/test_tutorial001.py::test_header_param_model_invalid
		tests/test_tutorial/test_header_param_models/test_tutorial003.py::test_header_param_model_invalid
		tests/test_tutorial/test_header_param_models/test_tutorial003.py::test_header_param_model_no_underscore
		# opentelemetry-*
		tests/test_telemetry/test_background.py::test_background_task_integrations
		tests/test_telemetry/test_data.py::test_request_objects_are_not_exported
		tests/test_telemetry/test_environment_integrations.py
		tests/test_telemetry/test_integrations.py::test_current_contrib
		tests/test_telemetry/test_integrations.py::test_current_logfire
		tests/test_telemetry/test_integrations.py::test_current_sentry
		tests/test_telemetry/test_integrations.py::test_inactive_sentry_does_not_disable_native
		tests/test_telemetry/test_integrations.py::test_logfire_global_provider_without_fastapi_instrumentor
		tests/test_telemetry/test_native_integrations.py
		tests/test_telemetry/test_runtime.py::test_concurrent_provider_owner_wins
		tests/test_telemetry/test_runtime.py::test_environment_export_initializes_after_fork
		tests/test_telemetry/test_runtime.py::test_failed_registration_closes_new_exporter
		tests/test_telemetry/test_runtime.py::test_real_otlp_exception_export_without_traces_or_metrics
		tests/test_telemetry/test_runtime.py::test_real_otlp_export_and_repeated_lifespans
		tests/test_telemetry/test_runtime.py::test_registration_provider_prefers_public_metric_reader
		tests/test_telemetry/test_runtime.py::test_unsupported_provider_warns_without_preventing_startup
		# TODO
		tests/test_dependency_contextmanager.py::test_{a,}sync_state
		tests/test_dependency_contextmanager.py::test_{a,}sync_raise_other
		# tutorial tests are flaky
		tests/test_tutorial/
	)
	epytest
}

pkg_postinst() {
	# not part of any upstream extra
	optfeature "alternative JSON library" "dev-python/ujson" # orjson, too but it's deprecated

	# pyproject.toml:project.optional-dependencies.standard
	# Following optfeatures should be exposed, but missing deps
	#	optfeature "fastAPI CLI" "dev-python/fastapi-cli" - missing - depends on this package!
	#	optfeature "compressed file support" "dev-python/fastar" - missing
	#	optfeature "pydantic extra types support" "dev-python/pydantic-extra-types" - in guru
	optfeature_header "standard extras"
	optfeature "ASGI server support" "dev-python/uvicorn"
	optfeature "email validation support" "dev-python/email-validator"
	optfeature "TestClient for testing FastAPI applications" "dev-python/httpx"
	optfeature "templating support" "dev-python/jinja2"
	optfeature "multipart form data support" "dev-python/python-multipart"
	optfeature "settings management support" "dev-python/pydantic-settings"

	# pyproject.toml:project.optional-dependencies.all - includes all the above plus:
	optfeature_header "all extras"
	optfeature "session middleware support" "dev-python/itsdangerous"
	optfeature "YAML support" "dev-python/pyyaml"
}