Skip to content

Commit 77c9190

Browse files
committed
🔨 use uv as source of python versions
1 parent 29c46c9 commit 77c9190

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

‎scripts/generate_matrix.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import importlib.metadata
55
import json
6+
import subprocess # noqa: S404
67
import sys
78
import urllib.error
89
import urllib.request
@@ -22,6 +23,26 @@
2223
)
2324

2425

26+
class UVPythonVersionParts(TypedDict):
27+
major: int
28+
minor: int
29+
patch: int
30+
31+
32+
class UVPythonRelease(TypedDict):
33+
name: str
34+
version: str
35+
version_parths: UVPythonVersionParts
36+
path: str | None
37+
symlink: str | None
38+
url: str | None
39+
os: str
40+
variant: str
41+
implementation: str
42+
arch: str
43+
libc: str
44+
45+
2546
class FileInfo(TypedDict, total=False):
2647
filename: str
2748
arch: str
@@ -124,16 +145,16 @@ def get_available_python_versions(
124145
urllib.error.URLError: If fetching data fails.
125146
126147
"""
127-
data: list[Release] = cast(
128-
"list[Release]",
129-
fetch_json("https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json"),
130-
)
148+
data_raw = subprocess.check_output(["uv", "python", "list", "--output-format=json"]) # noqa: S603, S607
149+
data = cast("list[UVPythonRelease]", json.loads(data_raw))
131150

132151
versions: dict[tuple[int, int], Version] = {}
133152

134-
for release in data[::-1]:
135-
version = parse(release["version"])
153+
for release in data:
154+
if release["implementation"] != "cpython" or release["variant"] != "default":
155+
continue
136156

157+
version = parse(release["version"])
137158
if version.is_prerelease and not pre_releases:
138159
continue
139160

0 commit comments

Comments
 (0)