From 3fe55e8fa368c88cbab75c76b040973cb34d86d3 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Jul 2025 11:56:37 +0200 Subject: [PATCH 1/3] toxgen: Detect correct sentry-sdk Sometimes after switching branches, importlib.metadata(sentry-sdk) would point to the wrong metadata (SDK 2.x instead of 3.x), which in turn meant toxgen would think the SDK supports different Python versions than it should. --- scripts/populate_tox/populate_tox.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/populate_tox/populate_tox.py b/scripts/populate_tox/populate_tox.py index 0aeb0f02ef..3d9e247b4f 100644 --- a/scripts/populate_tox/populate_tox.py +++ b/scripts/populate_tox/populate_tox.py @@ -10,7 +10,7 @@ from bisect import bisect_left from collections import defaultdict from datetime import datetime, timedelta, timezone # noqa: F401 -from importlib.metadata import metadata +from importlib.metadata import PackageMetadata, distributions from packaging.specifiers import SpecifierSet from packaging.version import Version from pathlib import Path @@ -88,6 +88,13 @@ } +def _fetch_sdk_metadata() -> PackageMetadata: + (dist,) = distributions( + name="sentry-sdk", path=[Path(__file__).parent.parent.parent] + ) + return dist.metadata + + def fetch_url(url: str) -> Optional[dict]: for attempt in range(3): pypi_data = requests.get(url) @@ -583,8 +590,9 @@ def main(fail_on_changes: bool = False) -> None: ) global MIN_PYTHON_VERSION, MAX_PYTHON_VERSION + meta = _fetch_sdk_metadata() sdk_python_versions = _parse_python_versions_from_classifiers( - metadata("sentry-sdk").get_all("Classifier") + meta.get_all("Classifier") ) MIN_PYTHON_VERSION = sdk_python_versions[0] MAX_PYTHON_VERSION = sdk_python_versions[-1] From 8d0692ddf5e48ee4abf13da0a597baa348933826 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Jul 2025 12:02:03 +0200 Subject: [PATCH 2/3] . --- scripts/generate-test-files.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/generate-test-files.sh b/scripts/generate-test-files.sh index 40e279cdf4..954c2c638a 100755 --- a/scripts/generate-test-files.sh +++ b/scripts/generate-test-files.sh @@ -6,6 +6,7 @@ set -xe cd "$(dirname "$0")" +rm -rf toxgen.venv python -m venv toxgen.venv . toxgen.venv/bin/activate @@ -13,5 +14,5 @@ pip install -e .. pip install -r populate_tox/requirements.txt pip install -r split_tox_gh_actions/requirements.txt -python populate_tox/populate_tox.py -python split_tox_gh_actions/split_tox_gh_actions.py +toxgen.venv/bin/python populate_tox/populate_tox.py +toxgen.venv/bin/python split_tox_gh_actions/split_tox_gh_actions.py From 4d7fd62178444c6ba1439f3ae54c051f93535a4c Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Jul 2025 12:09:47 +0200 Subject: [PATCH 3/3] make everything use venv stuff explicitly --- scripts/generate-test-files.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/generate-test-files.sh b/scripts/generate-test-files.sh index 954c2c638a..d1e0a7602c 100755 --- a/scripts/generate-test-files.sh +++ b/scripts/generate-test-files.sh @@ -10,9 +10,9 @@ rm -rf toxgen.venv python -m venv toxgen.venv . toxgen.venv/bin/activate -pip install -e .. -pip install -r populate_tox/requirements.txt -pip install -r split_tox_gh_actions/requirements.txt +toxgen.venv/bin/pip install -e .. +toxgen.venv/bin/pip install -r populate_tox/requirements.txt +toxgen.venv/bin/pip install -r split_tox_gh_actions/requirements.txt toxgen.venv/bin/python populate_tox/populate_tox.py toxgen.venv/bin/python split_tox_gh_actions/split_tox_gh_actions.py