Skip to content

Commit decd12a

Browse files
authored
Merge pull request #4352 from agriyakhetarpal/maintenance/pyodide-build-unvendoring
Handle Pyodide and pyodide-build unvendoring, and update Pyodide CI job
2 parents 6c024aa + 1622516 commit decd12a

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

.github/workflows/main.yml

+9-16
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ jobs:
223223
- name: Run tests
224224
run: TASK=${{ matrix.task }} ./build.sh
225225

226-
# See https://pyodide.org/en/stable/development/building-and-testing-packages.html#testing-packages-against-pyodide
226+
# See https://pyodide.org/en/stable/usage/building-and-testing-packages.html
227227
# and https://github.com/numpy/numpy/blob/9a650391651c8486d8cb8b27b0e75aed5d36033e/.github/workflows/emscripten.yml
228228
test-pyodide:
229229
runs-on: ubuntu-latest
230230
env:
231-
NODE_VERSION: 18
232-
# Note that the versions below must be updated in sync; we've automated
233-
# that with `update_pyodide_versions()` in our weekly cronjob.
234-
PYODIDE_VERSION: 0.27.3
231+
NODE_VERSION: 22
232+
# Note that the versions below are updated by `update_pyodide_versions()` in our weekly cronjob.
233+
# The versions of pyodide-build and the Pyodide runtime may differ.
234+
PYODIDE_VERSION: 0.27.5
235+
PYODIDE_BUILD_VERSION: 0.30.0
235236
PYTHON_VERSION: 3.12.7
236-
EMSCRIPTEN_VERSION: 3.1.58
237237
steps:
238238
- uses: actions/checkout@v3
239239
with:
@@ -246,17 +246,10 @@ jobs:
246246
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
247247
with:
248248
node-version: ${{ env.NODE_VERSION }}
249-
- name: Set up Emscripten
250-
uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
251-
with:
252-
version: ${{ env.EMSCRIPTEN_VERSION }}
253-
- name: Build
249+
- name: Install pyodide-build and Pyodide cross-build environment
254250
run: |
255-
# TODO remove https://github.com/pyodide/pyodide/issues/5585
256-
pip install -U wheel==0.45.1
257-
pip install pyodide-build==$PYODIDE_VERSION
258-
cd hypothesis-python/
259-
CFLAGS=-g2 LDFLAGS=-g2 pyodide build
251+
pip install pyodide-build==$PYODIDE_BUILD_VERSION
252+
pyodide xbuildenv install $PYODIDE_VERSION
260253
- name: Set up Pyodide venv and install dependencies
261254
run: |
262255
pip install --upgrade setuptools pip wheel==0.45.1 build

AUTHORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ their individual contributions.
1414
* `Adam Sven Johnson <https://www.github.com/pkqk>`_
1515
* `Afrida Tabassum <https://github.com/oxfordhalfblood>`_ ([email protected])
1616
* `Afonso Silva <https://github.com/ajcerejeira>`_ ([email protected])
17+
* `Agriya Khetarpal <https://github.com/agriyakhetarpal>`_
1718
* `Agustín Covarrubias <https://github.com/agucova>`_ ([email protected])
1819
* `Akash Suresh <https://www.github.com/akash-suresh>`_ ([email protected])
1920
* `Alex Gaynor <https://github.com/alex>`_

tooling/src/hypothesistooling/__main__.py

+48-14
Original file line numberDiff line numberDiff line change
@@ -403,31 +403,65 @@ def update_django_versions():
403403

404404

405405
def update_pyodide_versions():
406+
407+
def version_tuple(v: str) -> tuple[int, int, int]:
408+
return tuple(int(x) for x in v.split(".")) # type: ignore
409+
406410
vers_re = r"(\d+\.\d+\.\d+)"
407-
all_versions = re.findall(
411+
all_pyodide_build_versions = re.findall(
408412
f"pyodide_build-{vers_re}-py3-none-any.whl", # excludes pre-releases
409413
requests.get("https://pypi.org/simple/pyodide-build/").text,
410414
)
411-
for pyodide_version in sorted(
415+
pyodide_build_version = max(
412416
# Don't just pick the most recent version; find the highest stable version.
413-
set(all_versions),
414-
key=lambda version: tuple(int(x) for x in version.split(".")),
415-
reverse=True,
416-
):
417-
makefile_url = f"https://raw.githubusercontent.com/pyodide/pyodide/{pyodide_version}/Makefile.envs"
418-
match = re.search(
419-
rf"export PYVERSION \?= {vers_re}\nexport PYODIDE_EMSCRIPTEN_VERSION \?= {vers_re}\n",
420-
requests.get(makefile_url).text,
417+
set(all_pyodide_build_versions),
418+
key=version_tuple,
419+
)
420+
421+
cross_build_environments_url = "https://raw.githubusercontent.com/pyodide/pyodide/refs/heads/main/pyodide-cross-build-environments.json"
422+
cross_build_environments_data = requests.get(cross_build_environments_url).json()
423+
424+
# Find the latest stable release for the Pyodide runtime/xbuildenv that is compatible
425+
# with the pyodide-build version we found
426+
stable_releases = [
427+
release
428+
for release in cross_build_environments_data["releases"].values()
429+
if re.fullmatch(vers_re, release["version"])
430+
]
431+
432+
compatible_releases = []
433+
for release in stable_releases: # sufficiently large values
434+
min_build_version = release.get("min_pyodide_build_version", "0.0.0")
435+
max_build_version = release.get("max_pyodide_build_version", "999.999.999")
436+
437+
# Perform version comparisons to avoid getting an incompatible pyodide-build version
438+
# with the Pyodide runtime
439+
if (
440+
version_tuple(min_build_version)
441+
<= version_tuple(pyodide_build_version)
442+
<= version_tuple(max_build_version)
443+
):
444+
compatible_releases.append(release)
445+
446+
if not compatible_releases:
447+
raise RuntimeError(
448+
f"No compatible Pyodide release found for pyodide-build {pyodide_build_version}"
421449
)
422-
if match is not None:
423-
python_version, emscripten_version = match.groups()
424-
break
450+
451+
pyodide_release = max(
452+
compatible_releases,
453+
key=lambda release: version_tuple(release["version"]),
454+
)
455+
456+
pyodide_version = pyodide_release["version"]
457+
python_version = pyodide_release["python_version"]
458+
425459
ci_file = tools.ROOT / ".github/workflows/main.yml"
426460
config = ci_file.read_text(encoding="utf-8")
427461
for name, var in [
428462
("PYODIDE", pyodide_version),
463+
("PYODIDE_BUILD", pyodide_build_version),
429464
("PYTHON", python_version),
430-
("EMSCRIPTEN", emscripten_version),
431465
]:
432466
config = re.sub(f"{name}_VERSION: {vers_re}", f"{name}_VERSION: {var}", config)
433467
ci_file.write_text(config, encoding="utf-8")

0 commit comments

Comments
 (0)