Skip to content

Commit b42548f

Browse files
authored
🔨 use uv as source of python versions (#452)
2 parents b80a94a + 4d9d040 commit b42548f

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

‎.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424

25-
- uses: scientific-python/repo-review@v0.11.3
25+
- uses: scientific-python/repo-review@v0.12.1
2626
with:
2727
plugins: sp-repo-review
2828

‎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)