Skip to content

Commit a79fa74

Browse files
committed
Apply pyodide emscripten patches
1 parent c8b7323 commit a79fa74

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

.github/workflows/buildwheel.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Build
22

33
on: [push, pull_request]
44

5+
env:
6+
PYODIDE_VERSION: 0.28.2
7+
58
jobs:
69
build_wheels:
710
name: ${{ matrix.name }}
@@ -99,13 +102,25 @@ jobs:
99102
version: ${{ matrix.emscripten_version }}
100103
actions-cache-folder: emsdk-cache
101104

105+
- if: ${{ matrix.kind == 'pyodide' }}
106+
name: Check out Emscripten patches for Pyodide
107+
uses: actions/checkout@v6.0.2
108+
with:
109+
repository: pyodide/pyodide
110+
ref: ${{ env.PYODIDE_VERSION }}
111+
path: pyodide-patches
112+
sparse-checkout: |
113+
emsdk/patches/
114+
102115
# ------------- actual build ------------- #
103116

104117
- name: Build wheels
105118
uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
106119
env:
107120
CIBW_PLATFORM: ${{ matrix.cibw_platform }}
108121
CIBW_BUILD: ${{ matrix.cibw_build }}
122+
CIBW_PYODIDE_VERSION: ${{ env.PYODIDE_VERSION }}
123+
PYODIDE_EMSCRIPTEN_VERSION: ${{ matrix.kind == 'pyodide' && matrix.emscripten_version || '' }}
109124
# override setting in pyproject.toml to use msys2 instead of msys64 bash
110125
CIBW_BEFORE_ALL_WINDOWS: ${{ matrix.os == 'windows-11-arm' && 'msys2 -c bin/cibw_before_all_windows_arm64.sh' || 'msys2 -c bin/cibw_before_all_windows_amd64.sh' }}
111126

@@ -183,8 +198,6 @@ jobs:
183198
needs: build_wheels
184199
name: Test Pyodide wheel
185200
runs-on: ubuntu-22.04
186-
env:
187-
PYODIDE_VERSION: 0.28.2
188201

189202
steps:
190203
- uses: actions/setup-python@v6

bin/cibw_before_build_pyodide.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
python -m pip install wheel auditwheel_emscripten
6+
7+
EMSCRIPTEN_DIR="$HOME/.cache/cibuildwheel/emsdk-$PYODIDE_EMSCRIPTEN_VERSION/emsdk-$PYODIDE_EMSCRIPTEN_VERSION/upstream/emscripten"
8+
9+
for patch_file in pyodide-patches/emsdk/patches/*.patch; do
10+
echo "Applying Pyodide Emscripten patch $(basename "$patch_file")"
11+
patch -p1 --verbose -d "$EMSCRIPTEN_DIR" < "$patch_file"
12+
done

pyproject.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,10 @@ repair-wheel-command = [
179179

180180
[tool.cibuildwheel.pyodide]
181181
before-all = "bin/cibw_before_all_pyodide.sh"
182-
before-build = "pip install wheel auditwheel_emscripten"
182+
before-build = "bin/cibw_before_build_pyodide.sh"
183+
# The pyodide version is set in .github/workflows/buildwheel.yml as
184+
# CIBW_PYODIDE_VERSION because it is needed also for other things there.
183185

184-
# This needs to be kept in sync with the Pyodide row in
185-
# .github/workflows/buildwheel.yml. The Pyodide version pins both an
186-
# Emscripten version and a CPython minor version. The command
187-
# `pyodide xbuildenv search --all` shows the compatible combinations.
188-
pyodide-version = "0.28.2"
189-
190-
# GMP, MPFR, and FLINT are built as shared libraries for Pyodide and bundled
191-
# into the wheel.
192186
repair-wheel-command = [
193187
"""python bin/cibw_repair_wheel_licenses.py "{wheel}" \
194188
--license LGPL-3.0-or-later \

0 commit comments

Comments
 (0)