From f3bed0cbd961be3def0113db0c35a26804a565ee Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 30 Apr 2026 19:59:39 +0100 Subject: [PATCH 1/2] feat(python-version): support Python 3.9-3.14, first-class 3.12/3.13 Wide-support / narrow-first-class model for Python versions across the PyAuto family. Python 3.12 and 3.13 remain the recommended versions. 3.9, 3.10, 3.11, 3.14 install cleanly but emit a loud bypassable warning at import time. JAX moved to optional [jax] extra gated on python_version >= '3.11' (so 3.9/3.10 users get numpy-only mode without install failures). Coordinated change across PyAutoConf, PyAutoArray, PyAutoFit, PyAutoGalaxy, PyAutoLens, PyAutoBuild, and the 6 workspace repos. See sibling PRs on the feature/python-version-policy branch in each repo. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/main.yml | 2 +- autoconf/__init__.py | 64 ++++++++++++++++++++++++++++++++------ pyproject.toml | 21 +++++++++---- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c57f74..e8fb896 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - name: Checkout PyAutoConf uses: actions/checkout@v2 diff --git a/autoconf/__init__.py b/autoconf/__init__.py index db669f3..dbc9187 100644 --- a/autoconf/__init__.py +++ b/autoconf/__init__.py @@ -8,6 +8,7 @@ - :mod:`autoconf.csvable` — CSV (``output_to_csv`` / ``list_from_csv``) """ import sys +import warnings from pathlib import Path @@ -30,18 +31,61 @@ def _python_version_check_bypassed(): return False -if sys.version_info < (3, 12) and not _python_version_check_bypassed(): - raise RuntimeError( - f"Python {sys.version_info.major}.{sys.version_info.minor} detected. " - f"PyAutoConf is officially supported on Python 3.12+.\n" - f"Python 3.9, 3.10, and 3.11 will technically work but are not tested against.\n" - f"\n" - f"To bypass this check, add the following to your config/general.yaml:\n" - f"\n" - f" version:\n" - f" python_version_check: False\n" +_RECOMMENDED_PYTHON_VERSIONS = {(3, 12), (3, 13)} + + +def _emit_python_version_warning(): + current = sys.version_info[:2] + if current in _RECOMMENDED_PYTHON_VERSIONS: + return + if _python_version_check_bypassed(): + return + + py = f"{current[0]}.{current[1]}" + lines = [ + f"PyAuto: Python {py} detected -- first-class support is 3.12 and 3.13.", + "", + f"Things will probably work fine on {py}, but it is not the recommended", + "version and you may hit edge cases.", + ] + if current < (3, 11): + lines.extend( + [ + "", + "Note: JAX acceleration is not available on Python <3.11. Models", + "that pass use_jax=True will error.", + ] + ) + lines.extend( + [ + "", + "Recommended: install Python 3.12 or 3.13.", + "To silence this warning, add to /config/general.yaml:", + "", + " version:", + " python_version_check: False", + ] + ) + + inner_width = max(len(line) for line in lines) + border = "+" + "-" * (inner_width + 4) + "+" + framed = [border] + for line in lines: + framed.append("| " + line.ljust(inner_width) + " |") + framed.append(border) + + print("\n".join(framed), file=sys.stderr) + warnings.warn( + f"PyAuto: running on Python {py}; first-class support is 3.12/3.13. " + f"Suppress this warning via 'version.python_version_check: False' in " + f"config/general.yaml.", + UserWarning, + stacklevel=2, ) + +_emit_python_version_warning() + from . import jax_wrapper from . import exc from .tools.decorators import cached_property diff --git a/pyproject.toml b/pyproject.toml index bb897ec..9136f55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "PyAuto Configration" readme = { file = "README.rst", content-type = "text/x-rst" } license = { text = "MIT" } -requires-python = ">=3.12" +requires-python = ">=3.9" authors = [ { name = "James Nightingale", email = "James.Nightingale@newcastle.ac.uk" }, { name = "Richard Hayes", email = "richard@rghsoftware.co.uk" }, @@ -18,15 +18,16 @@ classifiers = [ "Topic :: Scientific/Engineering :: Physics", "Natural Language :: English", "Operating System :: OS Independent", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13" + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14" ] keywords = ["cli"] dependencies = [ "pathlib", - "jaxnnls==1.0.1", - "jax>=0.4.35,<0.10.0", - "jaxlib>=0.4.35,<0.10.0", "typing-inspect>=0.4.0", "PyYAML>=6.0.1", "numpy>=1.24.0,<3.0.0" @@ -46,7 +47,15 @@ version_scheme = "post-release" local_scheme = "no-local-version" [project.optional-dependencies] -optional=["astropy>=5.0"] +jax = [ + "jax>=0.4.35,<0.10.0; python_version >= '3.11'", + "jaxlib>=0.4.35,<0.10.0; python_version >= '3.11'", + "jaxnnls==1.0.1; python_version >= '3.11'" +] +optional = [ + "autoconf[jax]", + "astropy>=5.0" +] test = ["pytest"] dev = ["pytest", "black"] From ee2271f3c89cbcf5b3ef7159513a054e52a82332 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 30 Apr 2026 20:14:53 +0100 Subject: [PATCH 2/2] ci: narrow per-PR matrix to 3.12/3.13; install [optional] uniformly Per-PR CI now tests only the first-class Python versions (3.12, 3.13). Wide-span 3.9-3.14 verification moves to PyAutoBuild's python_matrix.yml workflow (weekly + on-demand). Install commands now always use the [optional] extra so JAX is available on both 3.12 and 3.13 (the conftest.py eager `import jax` was failing on 3.13 because the previous CI only added [optional] for 3.12). Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8fb896..5c57f74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + python-version: ['3.12', '3.13'] steps: - name: Checkout PyAutoConf uses: actions/checkout@v2