Skip to content

Commit d60fc2b

Browse files
authored
Support new graalpy asset names that include Python version. (#2863)
* Support new graalpy asset names that include Python version * Slight readability improvement for graalpy asset regex
1 parent 55c8985 commit d60fc2b

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎bin/update_pythons.py‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,22 @@ def __init__(self) -> None:
124124
response.raise_for_status()
125125

126126
releases = response.json()
127-
gp_version_re = re.compile(r"-(\d+\.\d+\.\d+)$")
127+
gp_asset_re = re.compile(
128+
r"^(?P<prefix>graalpy(?P<cpython>\d+\.\d+)?-(?P<graalpy>\d+\.\d+\.\d+))-"
129+
)
128130
cp_version_re = re.compile(r"Python (\d+\.\d+(?:\.\d+)?)")
129131
for release in releases:
130-
m = gp_version_re.search(release["tag_name"])
131-
if m:
132-
release["graalpy_version"] = Version(m.group(1))
133-
m = cp_version_re.search(release["body"])
134-
if m:
132+
for asset in release["assets"]:
133+
m = gp_asset_re.match(asset["name"])
134+
if m:
135+
release["asset_prefix"] = m.group("prefix")
136+
release["graalpy_version"] = Version(m.group("graalpy"))
137+
if m.group("cpython"):
138+
release["python_version"] = Version(m.group("cpython"))
139+
break
140+
if "python_version" not in release and (
141+
m := cp_version_re.search(release["body"] or "")
142+
):
135143
release["python_version"] = Version(m.group(1))
136144

137145
self.releases = [r for r in releases if "graalpy_version" in r and "python_version" in r]
@@ -172,12 +180,11 @@ def update_version(self, identifier: str, spec: Specifier) -> ConfigUrl | None:
172180
ext = "zip" if "win" in identifier else "tar.gz"
173181
for release in reversed(releases):
174182
version = release["python_version"]
175-
gpversion = release["graalpy_version"]
176183
urls = [
177184
rf["browser_download_url"]
178185
for rf in release["assets"]
179186
if rf["name"].endswith(f"{platform}-{arch}.{ext}")
180-
and rf["name"].startswith(f"graalpy-{gpversion.major}")
187+
and rf["name"].startswith(release["asset_prefix"])
181188
]
182189
if not urls:
183190
continue

0 commit comments

Comments
 (0)