Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-16 08:16:24

0001 #!/usr/bin/env -S uv run --script
0002 # /// script
0003 # requires-python = ">=3.11"
0004 # dependencies = [
0005 #     "packaging",
0006 # ]
0007 # ///
0008 # Prints information about the Python versions Acts supports, derived from
0009 # `requires-python` in the top-level pyproject.toml so that the wheel metadata,
0010 # cibuildwheel target matrix and the floor used to compile the requirements.txt
0011 # lockfiles all share one definition. `requires-python` only declares the floor
0012 # (an upper bound there is discouraged by PyPA packaging guidance and would
0013 # break installs on every future Python release); the ceiling of versions we
0014 # actually build/test for is declared here instead, via PYTHON_CEILING below.
0015 #
0016 # Usage:
0017 #   CI/supported_python_versions.py --floor    # lowest version, e.g. 3.10
0018 #   CI/supported_python_versions.py --cibw     # CIBW_BUILD value, e.g. "cp311-* cp312-*"
0019 
0020 import argparse
0021 import sys
0022 import tomllib
0023 from pathlib import Path
0024 
0025 from packaging.specifiers import SpecifierSet
0026 
0027 # Highest Python version Acts is built and tested for. Bump when a new
0028 # CPython release has been validated.
0029 PYTHON_CEILING = "3.14"
0030 
0031 
0032 def main() -> None:
0033     pyproject = Path(__file__).resolve().parent.parent / "pyproject.toml"
0034     with pyproject.open("rb") as f:
0035         raw = tomllib.load(f)["project"]["requires-python"]
0036     spec = SpecifierSet(raw) & SpecifierSet(f"<={PYTHON_CEILING}")
0037 
0038     parser = argparse.ArgumentParser()
0039     parser.add_argument("--floor", action="store_true")
0040     parser.add_argument("--cibw", action="store_true")
0041     args = parser.parse_args()
0042 
0043     all_versions = [f"3.{i}" for i in range(100)]
0044     versions = list(spec.filter(all_versions))
0045 
0046     if args.floor:
0047         print(versions[0])
0048         return
0049 
0050     if args.cibw:
0051         tags = ["cp" + v.replace(".", "") + "-*" for v in versions]
0052         print(" ".join(tags))
0053         return
0054 
0055     parser.print_help()
0056     sys.exit(1)
0057 
0058 
0059 if __name__ == "__main__":
0060     main()