From 30a361ca3cfffbdf38b9e580774f0e9847f39f53 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 23 Apr 2026 16:00:03 +0100 Subject: [PATCH] Soften Python version check with general.yaml bypass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hard 3.12+ check was preventing stable-but-older Python environments (e.g. the PyAutoGPU venv still on 3.10) from importing autoconf at all. The library actually runs fine on 3.9/3.10/3.11 — the 3.12 requirement was a support statement, not a functional dependency. The check now: - Reads `/config/general.yaml` for `version.python_version_check`. - If that key is `False`, import proceeds silently. - Otherwise raises with a clearer message that names the three Pythons that technically work and shows the YAML snippet to add to bypass. Any failure reading the config (missing file, bad YAML, missing key, missing `yaml` module) falls through to the raise, so the default behaviour on an unconfigured workspace is unchanged. Co-Authored-By: Claude Opus 4.7 --- autoconf/__init__.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/autoconf/__init__.py b/autoconf/__init__.py index 442c856..db669f3 100644 --- a/autoconf/__init__.py +++ b/autoconf/__init__.py @@ -8,11 +8,38 @@ - :mod:`autoconf.csvable` — CSV (``output_to_csv`` / ``list_from_csv``) """ import sys +from pathlib import Path -if sys.version_info < (3, 12): + +def _python_version_check_bypassed(): + """ + Return True iff the user's workspace config disables the Python version check. + + Reads ``/config/general.yaml`` and looks for ``version.python_version_check``. + Any failure (missing file, unreadable YAML, missing key, missing yaml module) is + treated as "not bypassed" so the default check still fires. + """ + try: + import yaml + + config_path = Path.cwd() / "config" / "general.yaml" + with config_path.open("r") as f: + data = yaml.safe_load(f) or {} + return data.get("version", {}).get("python_version_check") is False + except Exception: + return False + + +if sys.version_info < (3, 12) and not _python_version_check_bypassed(): raise RuntimeError( - f"PyAutoConf requires Python 3.12 or later. " - f"You are running Python {sys.version_info.major}.{sys.version_info.minor}." + 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" ) from . import jax_wrapper