Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
260 lines (249 loc) · 9.69 KB
/
Copy pathpyproject.toml
File metadata and controls
260 lines (249 loc) · 9.69 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
[project]
name = "lite-bootstrap"
description = "Lightweight bootstrap for production-ready Python microservices"
authors = [
{ name = "Artur Shiriev", email = "me@shiriev.ru" },
]
readme = "README.md"
requires-python = ">=3.11,<4"
license = "MIT"
keywords = ["microservices", "bootstrap", "opentelemetry", "sentry", "prometheus", "healthcheck", "fastapi", "litestar", "faststream", "structlog", "fastmcp", "python"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Typing :: Typed",
"Topic :: Software Development :: Libraries",
]
version = "0"
dependencies = [
# Runtime use: `typing_extensions.TypedDict` (healthchecks), required by pydantic/FastAPI on
# Python < 3.12 (`typing.TypedDict` is rejected there). Pure Python, so ft-friendly.
# >=4.6 because 4.4 and 4.5 raise on import under Python >=3.12 (they subclass `typing.TypeVar`).
# 4.7 to 4.13 install on 3.15 and fail at import: they read `typing.no_type_check_decorator`,
# which 3.15 removed. 4.14 is the first release after them.
"typing-extensions>=4.6; python_version < '3.15'",
"typing-extensions>=4.14; python_version >= '3.15'",
]
[project.urls]
Homepage = "https://lite-bootstrap.modern-python.org"
Documentation = "https://lite-bootstrap.modern-python.org"
Repository = "https://github.com/modern-python/lite-bootstrap"
Issues = "https://github.com/modern-python/lite-bootstrap/issues"
Changelog = "https://github.com/modern-python/lite-bootstrap/releases"
[project.optional-dependencies]
orjson = [
# No API forces this floor: only `orjson.dumps(...).decode()` and `orjson.loads`, both original.
# 3.8.0 is the first release with cp311 wheels for every platform.
"orjson>=3.8.0",
]
sentry = [
# >=2.70 for the top-level `data_collection` option, which SentryInstrument passes.
# <3 until sentry-sdk 3.0 is out of beta: it renames LoggingIntegration's arguments.
"sentry-sdk>=2.70,<3",
]
pyroscope = [
# >=0.7.2 for pyroscope.shutdown() (PyroscopeInstrument.teardown); 0.7.1 and below carry
# configure() without it, so teardown raises rather than failing at import. >=1.0.1 because
# add_thread_tag took (thread_id, key, value) until then and PyroscopeSpanProcessor calls it
# with (key, value) -- reached only when a span starts, so import and bootstrap both look fine.
"pyroscope-io>=1.0.1",
]
otl = [
# One release train: api/sdk/exporters 1.42 pair with every instrumentation package at
# 0.63b0. 1.42 is the first sdk whose base SpanProcessor.force_flush returns True rather
# than None, which PyroscopeSpanProcessor relies on. The exporters carry the floor
# separately: nothing else constrains them, so left bare they can resolve to a release
# that does not match the api.
"opentelemetry-api>=1.42",
"opentelemetry-sdk>=1.42",
"opentelemetry-exporter-otlp-proto-grpc>=1.42",
"opentelemetry-instrumentation>=0.63b0",
]
otl-http = [
"opentelemetry-api>=1.42",
"opentelemetry-sdk>=1.42",
"opentelemetry-exporter-otlp-proto-http>=1.42",
"opentelemetry-instrumentation>=0.63b0",
]
logging = [
# >=21.3 for structlog.stdlib.ProcessorFormatter.remove_processors_meta (LoggingInstrument's
# renderer chain). The library reads structlog.typing only under TYPE_CHECKING; the test suite
# imports it for real and needs 22.2, which is declared in [dependency-groups] dev instead.
"structlog>=21.3",
]
free-all = [
"lite-bootstrap[sentry,otl,logging,pyroscope]",
]
fastapi = [
"fastapi>=0.112.2",
# fastapi 0.112.2 requires typing-extensions>=4.8.
"typing-extensions>=4.8",
]
fastapi-sentry = [
"lite-bootstrap[fastapi,sentry]",
]
fastapi-otl = [
"lite-bootstrap[fastapi,otl]",
"opentelemetry-instrumentation-fastapi>=0.63b0",
]
fastapi-logging = [
"lite-bootstrap[fastapi,logging]",
]
fastapi-metrics = [
"lite-bootstrap[fastapi]",
# >=8.0.1 carries the _IncludedRouter fix required for FastAPI >=0.137
# (trallnag/prometheus-fastapi-instrumentator#370).
"prometheus-fastapi-instrumentator>=8.0.1",
# The instrumentator requires starlette>=1.0, which fastapi first allows at 0.133.
"fastapi>=0.133",
# The lowest typing-extensions fastapi 0.133's pydantic stack accepts.
"typing-extensions>=4.12",
]
fastapi-all = [
"lite-bootstrap[fastapi-sentry,fastapi-otl,fastapi-logging,fastapi-metrics,pyroscope]",
]
litestar = [
# >=2.13 for AppConfig.request_max_body_size (LitestarBootstrapper._apply_config reads it);
# >=2.15 for litestar.middleware.ASGIMiddleware (LitestarOpenTelemetryRouteMiddleware
# subclasses it); >=2.19 because litestar/concurrency.py imports sniffio and only 2.19 declares
# it -- until then it arrived via anyio, which dropped the dependency in 4.14; >=2.22 for
# litestar.plugins.opentelemetry (LitestarOpenTelemetryInstrument registers its
# OpenTelemetryPlugin). The highest wins.
"litestar>=2.22",
# litestar declares `typing-extensions` bare while importing typing_extensions.ReadOnly (4.9),
# so the floor has to come from here. >=4.12 rather than 4.9: 4.9 and 4.11 assign
# `typing.ParamSpec.__default__`, which Python 3.13 made read-only.
"typing-extensions>=4.12",
]
litestar-sentry = [
"lite-bootstrap[litestar,sentry]",
]
litestar-otl = [
"lite-bootstrap[litestar,otl]",
# Moves with the rest of the train: every instrumentation package pins
# `opentelemetry-instrumentation` to its own exact version.
"opentelemetry-instrumentation-asgi>=0.63b0",
]
litestar-logging = [
"lite-bootstrap[litestar,logging]",
# litestar's StructlogPlugin builds a stdlib logging config whose 'standard' formatter
# structlog cannot supply before 23.2, so LitestarBootstrapper raises ValueError during
# bootstrap. Higher than the 21.3 the `logging` extra needs on its own.
"structlog>=23.2",
]
litestar-metrics = [
"lite-bootstrap[litestar]",
"prometheus-client>=0.20",
]
litestar-all = [
"lite-bootstrap[litestar-sentry,litestar-otl,litestar-logging,litestar-metrics,pyroscope]",
]
faststream = [
# >=0.6 for faststream._internal.logger.params_storage.ManualLoggerStorage and for
# broker.config.logger.params_storage (FastStreamLoggingInstrument swaps and restores it).
"faststream>=0.6",
# pydantic requires typing-extensions>=4.12.2 on 3.13+; without this the lowest declared
# combination pins typing-extensions at 4.8 and drags pydantic back to a build that has no
# cp313 wheel either.
"typing-extensions>=4.12.2",
]
faststream-sentry = [
"lite-bootstrap[faststream,sentry]",
]
faststream-otl = [
"lite-bootstrap[faststream,otl]",
]
faststream-logging = [
"lite-bootstrap[faststream,logging]",
]
faststream-metrics = [
"lite-bootstrap[faststream]",
"prometheus-client>=0.20",
]
faststream-all = [
"lite-bootstrap[faststream-sentry,faststream-otl,faststream-logging,faststream-metrics,pyroscope]",
]
fastmcp = [
# >=4.0 so one middleware dispatch model is supported: from 4.0 the access log's on_message sees
# every inbound message, notifications included. <5 until 5.x is tested.
"fastmcp>=4.0,<5",
# fastmcp 4.0 pulls py-key-value-aio 0.4.4, which requires typing-extensions>=4.15.
"typing-extensions>=4.15",
]
fastmcp-otl = [
"lite-bootstrap[fastmcp,otl]",
"opentelemetry-instrumentation-asgi>=0.63b0",
]
fastmcp-metrics = [
"lite-bootstrap[fastmcp]",
"prometheus-client>=0.20",
# >=8.0.1 to share the fastapi-metrics floor; it requires starlette>=1.0, which fastmcp 4.0 already pulls.
"prometheus-fastapi-instrumentator>=8.0.1",
]
fastmcp-all = [
"lite-bootstrap[fastmcp,fastmcp-otl,fastmcp-metrics,sentry,logging,pyroscope]",
]
[dependency-groups]
dev = [
"pytest",
"pytest-cov",
"pytest-asyncio",
"httpx2", # for test client
"redis>=5.2.1",
# conftest imports structlog.typing at runtime, which the library does not. The suite's
# floor is higher than the one the `logging` extra publishes; this is where it belongs.
"structlog>=22.2",
# for the Taskiq recipe test only; Taskiq is not an extra.
"taskiq[opentelemetry]",
]
lint = [
"ty",
"ruff",
"eof-fixer",
]
[build-system]
requires = ["uv_build>=0.11,<1.0"]
build-backend = "uv_build"
[tool.uv.build-backend]
module-name = "lite_bootstrap"
module-root = ""
[tool.ruff]
fix = true
unsafe-fixes = true
line-length = 120
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D1", # docstrings are not forced; a docstring exists when it says something
"D203", # conflicts with D211
"D213", # conflicts with D212
"COM812", # conflicts with the formatter
"ISC001", # conflicts with the formatter
"CPY001", # no per-file copyright header
"FBT", # boolean positional arguments are fine
"TCH", # imports stay real; TYPE_CHECKING-only imports break runtime introspection
]
isort.lines-after-imports = 2
isort.no-lines-before = ["standard-library", "local-folder"]
[tool.ruff.lint.per-file-ignores]
"scripts/*.py" = ["INP001", "S101"] # standalone scripts, not an importable package; the smoke test asserts are its checks
"benchmarks/*.py" = ["INP001", "T201", "SLF001"] # standalone scripts: print tables, read SDK internals
"benchmarks/frameworks/*.py" = ["INP001", "T201", "SLF001"]
"tests/**" = ["S101"]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ""
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
[tool.coverage.report]
fail_under = 100
exclude_also = [
"if typing.TYPE_CHECKING:",
]