From 8c80c80cc2a70d8c925010818cb06ede17fd49ef Mon Sep 17 00:00:00 2001 From: Fayaz Yusuf Khan Date: Fri, 30 May 2025 15:34:33 -0400 Subject: [PATCH 1/2] Dynamically generate build matrix for all supported SQLAlchemy versions --- noxfile.py | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/noxfile.py b/noxfile.py index aab8502..5b58f95 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,6 +9,7 @@ # dependencies = [ # "nox", # "nox-uv", +# "requests", # ] # /// """ Entry point script for testing, linting, and development of the package. @@ -31,14 +32,17 @@ $ uv run noxfile.py -s dev -P 3.X $ uv run noxfile.py -s dev -P pypy-3.X # For PyPy """ +from itertools import groupby + import nox +from packaging.requirements import Requirement +from packaging.version import Version +import requests # Python versions supported and tested against: 3.8, 3.9, 3.10, 3.11 PYTHON_MINOR_VERSION_MIN = 8 PYTHON_MINOR_VERSION_MAX = 11 -# SQLAlchemy versions supported and tested against: 1.0, 1.1, 1.2, 1.3 -SQLALCHEMY_VERSIONS = ["1.0", "1.1", "1.2", "1.3"] nox.options.default_venv_backend = "uv" @@ -56,14 +60,37 @@ def lint(session): "--max-line-length=127", "--statistics", "--extend-exclude", ".venv") +def parametrize_test_versions(): + """Parametrize the session with all supported Python & SQLAlchemy versions.""" + response = requests.get("https://pypi.org/pypi/SQLAlchemy/json") + response.raise_for_status() + data = response.json() + all_major_and_minor_sqlalchemy_versions = [ + Version(f"{major}.{minor}") + for (major, minor), _ in groupby( + sorted(Version(version) for version in data["releases"].keys()), + key=lambda v: (v.major, v.minor) + ) + ] + + with open("requirements.txt", "r") as f: + requirement = Requirement(f.read().strip()) + filtered_sqlalchemy_versions = [ + version for version in all_major_and_minor_sqlalchemy_versions + if version in requirement.specifier + ] + + return [ + (f"{interpreter}3.{python_minor}", str(sqlalchemy_version)) + for interpreter in ("", "pypy-") + for python_minor in range(PYTHON_MINOR_VERSION_MIN, PYTHON_MINOR_VERSION_MAX + 1) + for sqlalchemy_version in filtered_sqlalchemy_versions + # SQLA 1.1 or below doesn't seem to support Python 3.10+ + if sqlalchemy_version >= Version("1.2") or python_minor <= 9] + + @nox.session() -@nox.parametrize("python,sqlalchemy", - [(f"{interpreter}3.{python_minor}", sqlalchemy_version) - for interpreter in ("", "pypy-") - for python_minor in range(PYTHON_MINOR_VERSION_MIN, PYTHON_MINOR_VERSION_MAX + 1) - for sqlalchemy_version in SQLALCHEMY_VERSIONS - # SQLA 1.1 or below doesn't seem to support Python 3.10+ - if sqlalchemy_version >= "1.2" or python_minor <= 9]) +@nox.parametrize("python,sqlalchemy", parametrize_test_versions()) def test(session, sqlalchemy): """Run tests with pytest. From 29cd8a3bf784bc14327f50fa5a46d3500767bd9b Mon Sep 17 00:00:00 2001 From: Fayaz Yusuf Khan Date: Fri, 30 May 2025 15:35:21 -0400 Subject: [PATCH 2/2] Fix formatting --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9ecb6fb..af9250b 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,9 @@ def read(name): include_package_data=True, zip_safe=False, license="MIT", - description="SQLAlchemy mixins for implementing tree-like models using Modified Pre-order Tree Traversal (MPTT) / Nested Sets", + description=( + "SQLAlchemy mixins for implementing tree-like models" + " using Modified Pre-order Tree Traversal (MPTT) / Nested Sets"), long_description=read("README.rst") + "\n" + read("CHANGES.rst"), install_requires=read("requirements.txt"), classifiers=[