Skip to content

Commit a51a97f

Browse files
Jammy2211Jammy2211claude
authored
feat(python-version): support Python 3.9-3.14, first-class 3.12/3.13 (#102)
* 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> --------- Co-authored-by: Jammy2211 <JNightingale2211@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 93ad7ca commit a51a97f

2 files changed

Lines changed: 69 additions & 16 deletions

File tree

autoconf/__init__.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- :mod:`autoconf.csvable` — CSV (``output_to_csv`` / ``list_from_csv``)
99
"""
1010
import sys
11+
import warnings
1112
from pathlib import Path
1213

1314

@@ -30,18 +31,61 @@ def _python_version_check_bypassed():
3031
return False
3132

3233

33-
if sys.version_info < (3, 12) and not _python_version_check_bypassed():
34-
raise RuntimeError(
35-
f"Python {sys.version_info.major}.{sys.version_info.minor} detected. "
36-
f"PyAutoConf is officially supported on Python 3.12+.\n"
37-
f"Python 3.9, 3.10, and 3.11 will technically work but are not tested against.\n"
38-
f"\n"
39-
f"To bypass this check, add the following to your config/general.yaml:\n"
40-
f"\n"
41-
f" version:\n"
42-
f" python_version_check: False\n"
34+
_RECOMMENDED_PYTHON_VERSIONS = {(3, 12), (3, 13)}
35+
36+
37+
def _emit_python_version_warning():
38+
current = sys.version_info[:2]
39+
if current in _RECOMMENDED_PYTHON_VERSIONS:
40+
return
41+
if _python_version_check_bypassed():
42+
return
43+
44+
py = f"{current[0]}.{current[1]}"
45+
lines = [
46+
f"PyAuto: Python {py} detected -- first-class support is 3.12 and 3.13.",
47+
"",
48+
f"Things will probably work fine on {py}, but it is not the recommended",
49+
"version and you may hit edge cases.",
50+
]
51+
if current < (3, 11):
52+
lines.extend(
53+
[
54+
"",
55+
"Note: JAX acceleration is not available on Python <3.11. Models",
56+
"that pass use_jax=True will error.",
57+
]
58+
)
59+
lines.extend(
60+
[
61+
"",
62+
"Recommended: install Python 3.12 or 3.13.",
63+
"To silence this warning, add to <cwd>/config/general.yaml:",
64+
"",
65+
" version:",
66+
" python_version_check: False",
67+
]
68+
)
69+
70+
inner_width = max(len(line) for line in lines)
71+
border = "+" + "-" * (inner_width + 4) + "+"
72+
framed = [border]
73+
for line in lines:
74+
framed.append("| " + line.ljust(inner_width) + " |")
75+
framed.append(border)
76+
77+
print("\n".join(framed), file=sys.stderr)
78+
warnings.warn(
79+
f"PyAuto: running on Python {py}; first-class support is 3.12/3.13. "
80+
f"Suppress this warning via 'version.python_version_check: False' in "
81+
f"config/general.yaml.",
82+
UserWarning,
83+
stacklevel=2,
4384
)
4485

86+
87+
_emit_python_version_warning()
88+
4589
from . import jax_wrapper
4690
from . import exc
4791
from .tools.decorators import cached_property

pyproject.toml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "PyAuto Configration"
99
readme = { file = "README.rst", content-type = "text/x-rst" }
1010
license = { text = "MIT" }
11-
requires-python = ">=3.12"
11+
requires-python = ">=3.9"
1212
authors = [
1313
{ name = "James Nightingale", email = "James.Nightingale@newcastle.ac.uk" },
1414
{ name = "Richard Hayes", email = "richard@rghsoftware.co.uk" },
@@ -18,15 +18,16 @@ classifiers = [
1818
"Topic :: Scientific/Engineering :: Physics",
1919
"Natural Language :: English",
2020
"Operating System :: OS Independent",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
2124
"Programming Language :: Python :: 3.12",
22-
"Programming Language :: Python :: 3.13"
25+
"Programming Language :: Python :: 3.13",
26+
"Programming Language :: Python :: 3.14"
2327
]
2428
keywords = ["cli"]
2529
dependencies = [
2630
"pathlib",
27-
"jaxnnls==1.0.1",
28-
"jax>=0.4.35,<0.10.0",
29-
"jaxlib>=0.4.35,<0.10.0",
3031
"typing-inspect>=0.4.0",
3132
"PyYAML>=6.0.1",
3233
"numpy>=1.24.0,<3.0.0"
@@ -46,7 +47,15 @@ version_scheme = "post-release"
4647
local_scheme = "no-local-version"
4748

4849
[project.optional-dependencies]
49-
optional=["astropy>=5.0"]
50+
jax = [
51+
"jax>=0.4.35,<0.10.0; python_version >= '3.11'",
52+
"jaxlib>=0.4.35,<0.10.0; python_version >= '3.11'",
53+
"jaxnnls==1.0.1; python_version >= '3.11'"
54+
]
55+
optional = [
56+
"autoconf[jax]",
57+
"astropy>=5.0"
58+
]
5059
test = ["pytest"]
5160
dev = ["pytest", "black"]
5261

0 commit comments

Comments
 (0)