Skip to content

Commit eb1ed56

Browse files
committed
feature: add GraalPy
1 parent baad277 commit eb1ed56

File tree

4 files changed

+98
-7
lines changed

4 files changed

+98
-7
lines changed

docker/build_scripts/manylinux-interpreters.py

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def sort_key(tag):
2121
python_tag, _ = tag.split("-")
2222
if python_tag.startswith(("cp", "pp")):
2323
return python_tag[:2], int(python_tag[2]), int(python_tag[3:])
24+
if python_tag.startswith("graalpy"):
25+
return python_tag[:7], int(python_tag[7]), int(python_tag[8:])
2426
raise LookupError(tag)
2527

2628

@@ -83,6 +85,12 @@ def get_info_from_tag(tag):
8385
"i": "pypy",
8486
"iv": PYTHON_TAGS[tag][ARCH]["version"]
8587
}
88+
if python_tag.startswith("graalpy"):
89+
return {
90+
"pv": f"{python_tag[7]}.{python_tag[8:]}",
91+
"i": "graalpy",
92+
"iv": PYTHON_TAGS[tag][ARCH]["version"]
93+
}
8694
raise LookupError(tag)
8795

8896

docker/build_scripts/python_versions.json

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
2+
"graalpy310-graalpy240_310_native": {
3+
"x86_64": {
4+
"version": "24.0.1",
5+
"download_url": "https://github.com/oracle/graalpython/releases/download/graal-24.0.1/graalpy-24.0.1-linux-amd64.tar.gz",
6+
"sha256": "c804a2a130866d50841c24e98b7c4d9257528fa97a6890344c6aa0710fb861ef"
7+
},
8+
"aarch64": {
9+
"version": "24.0.1",
10+
"download_url": "https://github.com/oracle/graalpython/releases/download/graal-24.0.1/graalpy-24.0.1-linux-aarch64.tar.gz",
11+
"sha256": "5c6fd064213d3be633c42183abd4f0d971145c43f99efc9831578a6ce99e2437"
12+
}
13+
},
214
"pp37-pypy37_pp73": {
315
"x86_64": {
416
"version": "7.3.9",

tests/run_tests.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ if [ "${AUDITWHEEL_POLICY:0:10}" == "musllinux_" ]; then
2121
EXPECTED_PYTHON_COUNT=9
2222
EXPECTED_PYTHON_COUNT_ALL=9
2323
else
24-
if [ "${AUDITWHEEL_ARCH}" == "x86_64" ] || [ "${AUDITWHEEL_ARCH}" == "i686" ] || [ "${AUDITWHEEL_ARCH}" == "aarch64" ]; then
24+
if [ "${AUDITWHEEL_ARCH}" == "x86_64" ] || [ "${AUDITWHEEL_ARCH}" == "aarch64" ]; then
25+
EXPECTED_PYTHON_COUNT=13
26+
EXPECTED_PYTHON_COUNT_ALL=14
27+
elif [ "${AUDITWHEEL_ARCH}" == "i686" ]; then
2528
EXPECTED_PYTHON_COUNT=13
2629
EXPECTED_PYTHON_COUNT_ALL=13
2730
else

tools/update_interpreters_download.py

+74-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import argparse
1010
import json
11+
import re
1112
import subprocess
1213
from hashlib import sha256
1314
from pathlib import Path
@@ -21,6 +22,15 @@
2122
PYTHON_VERSIONS = PROJECT_ROOT / "docker" / "build_scripts" / "python_versions.json"
2223

2324

25+
def get_sha256(url: str) -> str:
26+
response = requests.get(url, stream=True)
27+
response.raise_for_status()
28+
sha256sum = sha256()
29+
for chunk in response.iter_content(chunk_size=1024 * 4):
30+
sha256sum.update(chunk)
31+
return sha256sum.hexdigest()
32+
33+
2434
def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict, updates):
2535
pypy_arch = {"x86_64": "x64"}.get(arch, arch)
2636
current_version = None
@@ -42,14 +52,9 @@ def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict, upd
4252
continue
4353
message = f"updating {tag} {arch} to {r['pypy_version']}"
4454
print(message)
45-
response = requests.get(file["download_url"], stream=True)
46-
response.raise_for_status()
47-
sha256sum = sha256()
48-
for chunk in response.iter_content(chunk_size=1024 * 4):
49-
sha256sum.update(chunk)
5055
version_dict["version"] = str(r["pypy_version"])
5156
version_dict["download_url"] = file["download_url"]
52-
version_dict["sha256"] = sha256sum.hexdigest()
57+
version_dict["sha256"] = get_sha256(file["download_url"])
5358
updates.append(message)
5459
break
5560

@@ -88,13 +93,76 @@ def update_pypy_versions(versions, updates):
8893
)
8994

9095

96+
def update_graalpy_version(releases, graalpy_spec, tag, arch, version_dict, updates):
97+
graalpy_arch = {"x86_64": "amd64"}.get(arch, arch)
98+
current_version = None
99+
if "version" in version_dict:
100+
current_version = Version(version_dict["version"])
101+
for r in releases:
102+
version = Version(r["tag_name"].split('-')[1])
103+
if current_version is not None and current_version >= version:
104+
continue
105+
if not graalpy_spec.contains(version):
106+
continue
107+
asset_found = False
108+
for asset in r["assets"]:
109+
if asset["name"] == f"graalpy-{version}-linux-{graalpy_arch}.tar.gz":
110+
asset_found = True
111+
break
112+
if not asset_found:
113+
continue
114+
message = f"updating {tag} {arch} to {version}"
115+
print(message)
116+
version_dict["version"] = str(version)
117+
version_dict["download_url"] = asset["browser_download_url"]
118+
version_dict["sha256"] = get_sha256(asset["browser_download_url"])
119+
updates.append(message)
120+
break
121+
122+
123+
def get_next_page_link(response):
124+
link = response.headers.get("link")
125+
if link:
126+
for part in re.split(r"\s*,\s*", link):
127+
split = re.split(r"\s*;\s*", part)
128+
url = split[0][1:-1]
129+
for param in split[1:]:
130+
if re.match(r'rel="?next"?', param):
131+
return url
132+
133+
134+
def update_graalpy_versions(versions, updates):
135+
releases = []
136+
url = "https://api.github.com/repos/oracle/graalpython/releases"
137+
while url:
138+
response = requests.get(url)
139+
response.raise_for_status()
140+
releases += response.json()
141+
url = get_next_page_link(response)
142+
for tag in versions:
143+
if not tag.startswith("graalpy"):
144+
continue
145+
_, abi_tag = tag.split("-")
146+
graalpy_ver, _, _ = abi_tag.split("_")
147+
assert graalpy_ver.startswith("graalpy")
148+
graalpy_ver = graalpy_ver[len("graalpy"):]
149+
graalpy_major = int(graalpy_ver[:2])
150+
graalpy_minor = int(graalpy_ver[2:])
151+
graalpy_spec = Specifier(f"=={graalpy_major}.{graalpy_minor}.*")
152+
for arch in versions[tag]:
153+
update_graalpy_version(
154+
releases, graalpy_spec, tag, arch, versions[tag][arch], updates
155+
)
156+
157+
91158
def main():
92159
parser = argparse.ArgumentParser()
93160
parser.add_argument("--dry-run", dest="dry_run", action="store_true", help="dry run")
94161
args = parser.parse_args()
95162
versions = json.loads(PYTHON_VERSIONS.read_text())
96163
updates = []
97164
update_pypy_versions(versions, updates)
165+
update_graalpy_versions(versions, updates)
98166
if not args.dry_run:
99167
PYTHON_VERSIONS.write_text(json.dumps(versions, indent=2))
100168
if updates:

0 commit comments

Comments
 (0)