1+ import argparse
12from collections import defaultdict
23import requests
34import pathlib
45import yaml
56import re
67
7-
88_VERSIONS_URL = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" # noqa
99
10+ _OSX_PYTHON_EXCLUSIONS = ["3.11.0" , "3.12" , "3.14.0" , "3.14.1" , "3.14.2" , "3.14.3" ]
11+
1012
1113def parse_version (v ):
1214 return tuple (int (part ) for part in re .split (r"\W" , v )[:3 ])
@@ -50,18 +52,18 @@ def get_github_python_versions():
5052
5153 # for older versions of python, don't test all patches
5254 # (just test first and last) to keep the test matrix down
53- if major == 2 or minor <= 11 :
55+ if major == 2 or minor <= 12 :
5456 patches = [patches [0 ], patches [- 1 ]]
5557
56- if major == 3 and minor > 13 :
58+ if major == 3 and minor > 14 :
5759 continue
5860
5961 versions .extend (f"{ major } .{ minor } .{ patch } " for patch in patches )
6062
6163 return versions , platforms
6264
6365
64- def update_python_test_versions ():
66+ def update_python_test_versions (force = False ):
6567 versions , platforms = get_github_python_versions ()
6668 versions = sorted (versions , key = parse_version )
6769
@@ -72,7 +74,8 @@ def update_python_test_versions():
7274 build_yml = yaml .safe_load (open (build_yml_path ))
7375 test_matrix = build_yml ["jobs" ]["test-wheels" ]["strategy" ]["matrix" ]
7476 existing_python_versions = test_matrix ["python-version" ]
75- if versions == existing_python_versions :
77+ if not force and versions == existing_python_versions :
78+ print ("No new python versions found - not updating github actions" )
7679 return
7780
7881 print ("Adding new versions" )
@@ -96,9 +99,12 @@ def update_python_test_versions():
9699 # since it currently fails in GHA on SIP errors
97100 exclusions = []
98101 for v in versions :
99- # if we don't have a python version for osx/windows skip
100- if ("darwin" , "x64" ) not in platforms [v ] or v .startswith ("3.12" ):
101- exclusions .append (" - os: macos-13\n " )
102+ # if we don't have a python version for the platform, skip it in GHA
103+ # also, ignore python 3.12.* and 3.14.0 to 3.14.3 on OSX
104+ if ("darwin" , "arm64" ) not in platforms [v ] or any (
105+ v .startswith (pattern ) for pattern in _OSX_PYTHON_EXCLUSIONS
106+ ):
107+ exclusions .append (" - os: macos-latest\n " )
102108 exclusions .append (f" python-version: { v } \n " )
103109
104110 if ("win32" , "x64" ) not in platforms [v ]:
@@ -122,4 +128,15 @@ def update_python_test_versions():
122128
123129
124130if __name__ == "__main__" :
125- update_python_test_versions ()
131+ parser = argparse .ArgumentParser (
132+ description = "Updates github actions with new python versions" ,
133+ formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
134+ )
135+ parser .add_argument (
136+ "--force" ,
137+ help = "Run script even if there are no new python versions" ,
138+ action = "store_true" ,
139+ )
140+ args = parser .parse_args ()
141+
142+ update_python_test_versions (force = args .force )
0 commit comments