Skip to content

Commit e13b7a7

Browse files
authored
feat: Add script to determine lowest supported versions (#4867)
### Description With toxgen, we now have an automated way of detecting the effective minimum version of a framework. This depends on both package metadata (e.g., the min version needs to support at least some of the Python versions we support) as well as on our test matrix and explicitly defined lower bounds (in `sentry_sdk/integrations/__init__.py`'s `_MIN_VERSIONS`). When we release a new major in which we drop support for a Python version, we can use this script to automatically generate the new `_MIN_VERSIONS`. Example output: ``` Effective minimal versions: - The format is the same as _MIN_VERSIONS in sentry_sdk/integrations/__init__.py for easy replacing. - When updating these, make sure to also update: - The docs page for the integration - The lower bounds in extras_require in setup.py "aiohttp": (3, 4, 4), "anthropic": (0, 16, 0), "ariadne": (0, 20, 1), "arq": (0, 23), "asyncpg": (0, 23, 0), "beam": (2, 14, 0), "boto3": (1, 12, 49), "bottle": (0, 12, 25), "celery": (4, 4, 7), "chalice": (1, 16, 0), "clickhouse_driver": (0, 2, 9), "cohere": (5, 4, 0), "django": (1, 11, 29), "dramatiq": (1, 9, 0), "falcon": (1, 4, 1), "fastapi": (0, 79, 1), "flask": (1, 1, 4), "gql": (3, 4, 1), "graphene": (3, 3), "grpc": (1, 32, 0), "httpx": (0, 16, 1), "huey": (2, 1, 3), "huggingface_hub": (0, 24, 7), "langchain": (0, 1, 20), "langgraph": (0, 6, 7), "launchdarkly": (9, 8, 1), "litestar": (2, 0, 1), "loguru": (0, 7, 3), "openai": (1, 0, 1), "openai_agents": (0, 0, 19), "openfeature": (0, 7, 5), "pure_eval": (0, 0, 3), "pymongo": (3, 5, 1), "pyramid": (1, 8, 6), "quart": (0, 16, 3), "ray": (2, 7, 2), "redis": (2, 10, 6), "redis_py_cluster_legacy": (1, 3, 6), "requests": (2, 12, 5), "rq": (0, 8, 2), "sanic": (0, 8, 3), "spark": (3, 0, 3), "sqlalchemy": (1, 3, 24), "starlette": (0, 16, 0), "starlite": (1, 48, 1), "statsig": (0, 55, 3), "strawberry": (0, 209, 8), "tornado": (6, 0, 4), "trytond": (4, 6, 22), "typer": (0, 15, 4), "unleash": (6, 0, 1), ``` #### Issues Ref #4047 #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 7e493b4 commit e13b7a7

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

scripts/populate_tox/populate_tox.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def _normalize_release(release: dict) -> dict:
665665
return normalized
666666

667667

668-
def main(fail_on_changes: bool = False) -> None:
668+
def main(fail_on_changes: bool = False) -> dict[str, list]:
669669
"""
670670
Generate tox.ini from the tox.jinja template.
671671
@@ -825,6 +825,8 @@ def main(fail_on_changes: bool = False) -> None:
825825
"files to reflect the new test targets."
826826
)
827827

828+
return packages
829+
828830

829831
if __name__ == "__main__":
830832
fail_on_changes = len(sys.argv) == 2 and sys.argv[1] == "--fail-on-changes"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Small utility to determine the actual minimum supported version of each framework/library.
3+
"""
4+
5+
import os
6+
import sys
7+
from textwrap import dedent
8+
9+
populate_tox_dir = os.path.join(
10+
os.path.dirname(os.path.abspath(__file__)), "populate_tox"
11+
)
12+
sys.path.append(populate_tox_dir)
13+
14+
from populate_tox import main
15+
16+
17+
def update():
18+
print("Running populate_tox.py...")
19+
packages = main()
20+
21+
print("Figuring out the lowest supported version of integrations...")
22+
min_versions = []
23+
24+
for _, integrations in packages.items():
25+
for integration in integrations:
26+
min_versions.append(
27+
(integration["integration_name"], str(integration["releases"][0]))
28+
)
29+
30+
min_versions = sorted(
31+
set(
32+
[
33+
(integration, tuple([int(v) for v in min_version.split(".")]))
34+
for integration, min_version in min_versions
35+
]
36+
)
37+
)
38+
39+
print()
40+
print("Effective minimal versions:")
41+
print(
42+
dedent("""
43+
- The format is the same as _MIN_VERSIONS in sentry_sdk/integrations/__init__.py for easy replacing.
44+
- When updating these, make sure to also update:
45+
- The docs page for the integration
46+
- The lower bounds in extras_require in setup.py
47+
""")
48+
)
49+
print()
50+
for integration, min_version in min_versions:
51+
print(f'"{integration}": {min_version},')
52+
53+
54+
if __name__ == "__main__":
55+
update()

0 commit comments

Comments
 (0)