From 7d29312b75fdd5bd43346ab2d954e1d370b9c2e2 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 20:15:37 +0000 Subject: [PATCH 01/18] Use cibuildwheel to build pyodide wheels --- .github/workflows/ci-emscripten.yml | 77 +++++------------------------ bin/build_dependencies_unix.sh | 1 + bin/build_variables.sh | 8 ++- bin/build_wheel.sh | 1 + bin/cibw_before_all_pyodide.sh | 18 +++++++ bin/pyodide_build_dependencies.sh | 9 +++- pyproject.toml | 18 +++++++ 7 files changed, 61 insertions(+), 71 deletions(-) create mode 100755 bin/cibw_before_all_pyodide.sh diff --git a/.github/workflows/ci-emscripten.yml b/.github/workflows/ci-emscripten.yml index 27f1741b..55c66a89 100644 --- a/.github/workflows/ci-emscripten.yml +++ b/.github/workflows/ci-emscripten.yml @@ -15,93 +15,42 @@ jobs: build: runs-on: ubuntu-latest env: - PYODIDE_VERSION: "https://github.com/pyodide/pyodide-build-environment-nightly/releases/download/20250523-emscripten_4.0.9/xbuildenv.tar.bz2" PYTHON_VERSION: 3.13 # any 3.13.x version works - EMSCRIPTEN_VERSION: 4.0.9 NODE_VERSION: 22 steps: - - uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.2.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@2e3e4b15a884dc73a63f962bff250a855150a234 # v5.4.0 + uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - - name: Set up Emscripten toolchain - uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 - with: - version: ${{ env.EMSCRIPTEN_VERSION }} - actions-cache-folder: emsdk-cache - - name: Set up Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + uses: actions/setup-node@v6 with: node-version: ${{ env.NODE_VERSION }} - - name: Install pyodide-build - run: | - pip install pyodide-build - pyodide xbuildenv install --url ${{ env.PYODIDE_VERSION }} - - name: Restore WASM library directory from cache id: cache-wasm-library-dir uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 + key: wasm-library-dir-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - - name: Build GMP, MPFR and FLINT - if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' + - name: Build and test Pyodide wheel + uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 env: - CFLAGS: "-fPIC" - run: bin/pyodide_build_dependencies.sh --wasm-library-dir ${{ github.workspace }}/wasm-library-dir + CIBW_PLATFORM: pyodide + CIBW_BUILD: cp313-* - name: Persist WASM library directory to cache + if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ hashFiles('bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - - - name: Restore python-flint build directory from cache - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}/flint_wasm_build - key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} - - - name: Build python-flint - env: - WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir - run: | - export PKG_CONFIG_PATH="${{ env.WASM_LIBRARY_DIR }}/lib/pkgconfig:${PKG_CONFIG_PATH}" - export CFLAGS="-I${{ env.WASM_LIBRARY_DIR }}/include ${CFLAGS:-}" - export LDFLAGS="-L${{ env.WASM_LIBRARY_DIR }}/lib -lflint -lmpfr -lgmp ${LDFLAGS:-}" - - echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" - echo "CFLAGS=${CFLAGS}" - echo "LDFLAGS=${LDFLAGS}" - - pkg-config --modversion python3 - pkg-config --modversion mpfr - pkg-config --modversion flint + key: wasm-library-dir-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - pyodide build -Cbuild-dir=flint_wasm_build -Csetup-args="-Dflint_version_check=false" - - - name: Persist python-flint build directory to cache - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + - uses: actions/upload-artifact@v7 with: - path: ${{ github.workspace }}/flint_wasm_build - key: flint-wasm-build-${{ hashFiles('**/meson.build', '**/pyproject.toml', '**/setup.py') }} - - - name: Set up Pyodide virtual environment and test python-flint - run: | - pyodide venv .venv-pyodide - - source .venv-pyodide/bin/activate - pip install dist/*.whl - - cd doc - - pip install pytest hypothesis - # Don't use the cache provider plugin, as it doesn't work with Pyodide - # right now: https://github.com/pypa/cibuildwheel/issues/1966 - pytest -svra -p no:cacheprovider --pyargs flint + name: wheels-pyodide + path: wheelhouse/*.whl diff --git a/bin/build_dependencies_unix.sh b/bin/build_dependencies_unix.sh index d7a9d33d..7a38f8c0 100755 --- a/bin/build_dependencies_unix.sh +++ b/bin/build_dependencies_unix.sh @@ -140,6 +140,7 @@ done source bin/build_variables.sh +mkdir -p "$PREFIX" cd $PREFIX mkdir -p src cd src diff --git a/bin/build_variables.sh b/bin/build_variables.sh index cf7bb143..256f4d84 100644 --- a/bin/build_variables.sh +++ b/bin/build_variables.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash # -# Create a local directory .local to be used as --prefix when building -# local installs of python-flint's dependencies. This also sets the PREFIX -# shell variable and environment variables giving the versions to use for each -# dependency. This script should be sourced rather than executed e.g.: +# Set the PREFIX shell variable and environment variables giving the versions +# to use for each dependency. This script should be sourced rather than +# executed e.g.: # # $ source bin/build_variables.sh # @@ -11,7 +10,6 @@ # executed directly. PREFIX=$(pwd)/.local -mkdir -p $PREFIX ARBVER=2.23.0 # Not needed with flint >= 3.0.0 (Arb is included in flint) diff --git a/bin/build_wheel.sh b/bin/build_wheel.sh index e881dda6..8d5d39da 100755 --- a/bin/build_wheel.sh +++ b/bin/build_wheel.sh @@ -7,6 +7,7 @@ set -o errexit source bin/build_variables.sh +mkdir -p "$PREFIX" python3 -m venv $PREFIX/venv source $PREFIX/venv/bin/activate pip install -U pip diff --git a/bin/cibw_before_all_pyodide.sh b/bin/cibw_before_all_pyodide.sh new file mode 100755 index 00000000..15e4e2bf --- /dev/null +++ b/bin/cibw_before_all_pyodide.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +PROJECT_DIR=$(cd -- "$SCRIPT_DIR/.." && pwd) +WASM_LIBRARY_DIR=${WASM_LIBRARY_DIR:-"$PROJECT_DIR/wasm-library-dir"} + +if [ -f "$WASM_LIBRARY_DIR/lib/pkgconfig/flint.pc" ]; then + echo "Using cached Pyodide dependencies from $WASM_LIBRARY_DIR" + exit 0 +fi + +mkdir -p "$WASM_LIBRARY_DIR" + +export CFLAGS="-fPIC ${CFLAGS:-}" + +"$SCRIPT_DIR/pyodide_build_dependencies.sh" --wasm-library-dir "$WASM_LIBRARY_DIR" diff --git a/bin/pyodide_build_dependencies.sh b/bin/pyodide_build_dependencies.sh index dd594d45..d58af513 100755 --- a/bin/pyodide_build_dependencies.sh +++ b/bin/pyodide_build_dependencies.sh @@ -2,6 +2,8 @@ set -e +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) + while [[ $# -gt 0 ]] do key="$1" @@ -43,9 +45,12 @@ if [ -z "$WASM_LIBRARY_DIR" ]; then exit 1 fi +mkdir -p "$WASM_LIBRARY_DIR/src" +cd "$WASM_LIBRARY_DIR/src" + # Sets versions of GMP, MPFR and FLINT: -source bin/build_variables.sh +source "$SCRIPT_DIR/build_variables.sh" # Download mirrored copy of source distributions for GMP and MPFR @@ -106,7 +111,7 @@ fi # Patch needed for FLINT == 3.4.0 # This is https://github.com/flintlib/flint/pull/2594 - patch -N -Z -p1 < ../bin/patch-flint-emscripten-profiler.diff + patch -N -Z -p1 < "$SCRIPT_DIR/patch-flint-emscripten-profiler.diff" ./bootstrap.sh diff --git a/pyproject.toml b/pyproject.toml index 399b0e23..9899fb11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -176,3 +176,21 @@ repair-wheel-command = [ """, "delvewheel repair -w {dest_dir} {wheel} --add-path .local/bin", ] + +[tool.cibuildwheel.pyodide] +before-all = "bin/cibw_before_all_pyodide.sh" +pyodide-version = "0.28.2" +# GMP, MPFR, and FLINT are built as static libraries for Pyodide. +repair-wheel-command = "" +test-command = "python -m pytest -svra -p no:cacheprovider --pyargs flint" +test-requires = ["pytest", "hypothesis"] + +[tool.cibuildwheel.pyodide.environment] +WASM_LIBRARY_DIR = "$(pwd)/wasm-library-dir" +PKG_CONFIG_PATH = "$(pwd)/wasm-library-dir/lib/pkgconfig:$PKG_CONFIG_PATH" +CFLAGS = "-I$(pwd)/wasm-library-dir/include $CFLAGS" +LDFLAGS = "-L$(pwd)/wasm-library-dir/lib -lflint -lmpfr -lgmp $LDFLAGS" + +[tool.cibuildwheel.pyodide.config-settings] +build-dir = "flint_wasm_build" +setup-args = ["-Dflint_version_check=false"] From 6d15e42954cb3632b1b5c4883c15e9f81627352f Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 20:26:00 +0000 Subject: [PATCH 02/18] Add back the emscripten toolchain --- .github/workflows/ci-emscripten.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci-emscripten.yml b/.github/workflows/ci-emscripten.yml index 55c66a89..62e8cf2e 100644 --- a/.github/workflows/ci-emscripten.yml +++ b/.github/workflows/ci-emscripten.yml @@ -16,6 +16,7 @@ jobs: runs-on: ubuntu-latest env: PYTHON_VERSION: 3.13 # any 3.13.x version works + EMSCRIPTEN_VERSION: 4.0.9 NODE_VERSION: 22 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -25,6 +26,12 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} + - name: Set up Emscripten toolchain + uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 + with: + version: ${{ env.EMSCRIPTEN_VERSION }} + actions-cache-folder: emsdk-cache + - name: Set up Node.js uses: actions/setup-node@v6 with: From 568d91dc438fac6bd0351f2fa88320cafb72ffee Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 20:40:00 +0000 Subject: [PATCH 03/18] Unset comiler flags for before_all --- bin/cibw_before_all_pyodide.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/cibw_before_all_pyodide.sh b/bin/cibw_before_all_pyodide.sh index 15e4e2bf..a1cc8707 100755 --- a/bin/cibw_before_all_pyodide.sh +++ b/bin/cibw_before_all_pyodide.sh @@ -13,6 +13,13 @@ fi mkdir -p "$WASM_LIBRARY_DIR" -export CFLAGS="-fPIC ${CFLAGS:-}" +# The Pyodide cibuildwheel environment for building python-flint itself sets +# include/library flags that reference libgmp/libmpfr/libflint. Those libraries +# do not exist yet while bootstrapping the static dependencies here, so letting +# them leak into configure would break link tests such as "does the C compiler +# work?" for GMP. Use a minimal environment for the bootstrap step. +unset PKG_CONFIG_PATH +unset LDFLAGS +export CFLAGS="-fPIC" "$SCRIPT_DIR/pyodide_build_dependencies.sh" --wasm-library-dir "$WASM_LIBRARY_DIR" From 5794e26191369699da7cfa9d1e255627294c96d1 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 21:00:41 +0000 Subject: [PATCH 04/18] Add a meson.cross file for pyodide cross-build. --- bin/emscripten.meson.cross | 15 +++++++++++++++ pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 bin/emscripten.meson.cross diff --git a/bin/emscripten.meson.cross b/bin/emscripten.meson.cross new file mode 100644 index 00000000..4e59690c --- /dev/null +++ b/bin/emscripten.meson.cross @@ -0,0 +1,15 @@ +# compiler paths are omitted intentionally so pyodide-build can override them +# with its pywasmcross wrappers. +[binaries] +exe_wrapper = 'node' +pkgconfig = 'pkg-config' + +[properties] +needs_exe_wrapper = true +skip_sanity_check = true + +[host_machine] +system = 'emscripten' +cpu_family = 'wasm32' +cpu = 'wasm' +endian = 'little' diff --git a/pyproject.toml b/pyproject.toml index 9899fb11..2249d473 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,4 +193,4 @@ LDFLAGS = "-L$(pwd)/wasm-library-dir/lib -lflint -lmpfr -lgmp $LDFLAGS" [tool.cibuildwheel.pyodide.config-settings] build-dir = "flint_wasm_build" -setup-args = ["-Dflint_version_check=false"] +setup-args = ["--cross-file=$PWD/bin/emscripten.meson.cross", "-Dflint_version_check=false"] From afe2b144dbfaa69e68477fa4520310154a625536 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 22:00:14 +0000 Subject: [PATCH 05/18] Try to get meson to find the pyodide Python headers... --- meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 63323bb9..e126d3c6 100644 --- a/meson.build +++ b/meson.build @@ -21,7 +21,13 @@ cython_lower = '>=3.0.11' cython_upper = '<3.3' py = import('python').find_installation(pure: false) -dep_py = py.dependency() +if meson.is_cross_build() and host_machine.system() == 'emscripten' + # Avoid picking up the runner's host python.pc via pkg-config. + # For Pyodide, use the interpreter sysconfig data from pyodide-build instead. + dep_py = py.dependency(method: 'system') +else + dep_py = py.dependency() +endif cc = meson.get_compiler('c') cy = meson.get_compiler('cython') From feaa3544283313bd3c3d2be752cf4749b63e1a1c Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 22:35:51 +0000 Subject: [PATCH 06/18] Add license files to pyodide wheels --- pyproject.toml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2249d473..a2b0be88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,9 +179,21 @@ repair-wheel-command = [ [tool.cibuildwheel.pyodide] before-all = "bin/cibw_before_all_pyodide.sh" +before-build = "pip install wheel" pyodide-version = "0.28.2" # GMP, MPFR, and FLINT are built as static libraries for Pyodide. -repair-wheel-command = "" +repair-wheel-command = [ +"""python bin/cibw_repair_wheel_licenses.py "{wheel}" \ + --license LGPL-3.0-or-later \ + --license-file 'wasm-library-dir/src/gmp-*/COPYING:python-flint.libs/gmp-*/COPYING' \ + --license-file 'wasm-library-dir/src/gmp-*/COPYING.LESSERv3:python-flint.libs/gmp-*/COPYING.LESSERv3' \ + --license-file 'wasm-library-dir/src/mpfr-*/COPYING:python-flint.libs/mpfr-*/COPYING' \ + --license-file 'wasm-library-dir/src/mpfr-*/COPYING.LESSER:python-flint.libs/mpfr-*/COPYING.LESSER' \ + --license-file 'wasm-library-dir/src/flint-*/COPYING:python-flint.libs/flint-*/COPYING' \ + --license-file 'wasm-library-dir/src/flint-*/COPYING.LESSER:python-flint.libs/flint-*/COPYING.LESSER' \ +""", +"cp \"{wheel}\" \"{dest_dir}\"", +] test-command = "python -m pytest -svra -p no:cacheprovider --pyargs flint" test-requires = ["pytest", "hypothesis"] From 415dafe292d97445131f73142573b9e130851080 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 23:00:37 +0000 Subject: [PATCH 07/18] Remove unneeded github actions in ci-emscripten.yml --- .github/workflows/ci-emscripten.yml | 14 ++------------ pyproject.toml | 7 +++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-emscripten.yml b/.github/workflows/ci-emscripten.yml index 62e8cf2e..760eada5 100644 --- a/.github/workflows/ci-emscripten.yml +++ b/.github/workflows/ci-emscripten.yml @@ -15,28 +15,17 @@ jobs: build: runs-on: ubuntu-latest env: - PYTHON_VERSION: 3.13 # any 3.13.x version works + # This needs to be kept in sync with pyodide-version in pyproject.toml EMSCRIPTEN_VERSION: 4.0.9 - NODE_VERSION: 22 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v6 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Set up Emscripten toolchain uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 with: version: ${{ env.EMSCRIPTEN_VERSION }} actions-cache-folder: emsdk-cache - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: ${{ env.NODE_VERSION }} - - name: Restore WASM library directory from cache id: cache-wasm-library-dir uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 @@ -48,6 +37,7 @@ jobs: uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 env: CIBW_PLATFORM: pyodide + # This needs to be kept in sync with pyodide-version in pyproject.toml CIBW_BUILD: cp313-* - name: Persist WASM library directory to cache diff --git a/pyproject.toml b/pyproject.toml index a2b0be88..e8760cfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -180,7 +180,14 @@ repair-wheel-command = [ [tool.cibuildwheel.pyodide] before-all = "bin/cibw_before_all_pyodide.sh" before-build = "pip install wheel" + +# This needs to be kept in sync with EMSCRIPTEN_VERSION and CIBW_BUILD in +# .github.workflows/ci-emscripten.yml. The pyodide version pins both an +# emscripten version and a CPython minor version. Not sure what is a good link +# to see a table of versions but the command pyodide xbuildenv search --all +# shows this. pyodide-version = "0.28.2" + # GMP, MPFR, and FLINT are built as static libraries for Pyodide. repair-wheel-command = [ """python bin/cibw_repair_wheel_licenses.py "{wheel}" \ From 920ced0e7221bf7b702b6cacb1b15e3f1168a6c0 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 23:42:22 +0000 Subject: [PATCH 08/18] Remove unneeded cross file --- bin/emscripten.meson.cross | 15 --------------- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 bin/emscripten.meson.cross diff --git a/bin/emscripten.meson.cross b/bin/emscripten.meson.cross deleted file mode 100644 index 4e59690c..00000000 --- a/bin/emscripten.meson.cross +++ /dev/null @@ -1,15 +0,0 @@ -# compiler paths are omitted intentionally so pyodide-build can override them -# with its pywasmcross wrappers. -[binaries] -exe_wrapper = 'node' -pkgconfig = 'pkg-config' - -[properties] -needs_exe_wrapper = true -skip_sanity_check = true - -[host_machine] -system = 'emscripten' -cpu_family = 'wasm32' -cpu = 'wasm' -endian = 'little' diff --git a/pyproject.toml b/pyproject.toml index e8760cfe..2a7da7fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -212,4 +212,4 @@ LDFLAGS = "-L$(pwd)/wasm-library-dir/lib -lflint -lmpfr -lgmp $LDFLAGS" [tool.cibuildwheel.pyodide.config-settings] build-dir = "flint_wasm_build" -setup-args = ["--cross-file=$PWD/bin/emscripten.meson.cross", "-Dflint_version_check=false"] +setup-args = ["-Dflint_version_check=false"] From 4dfaf9a72224bdd2871aa1787e76d2ef653078bd Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Mon, 23 Mar 2026 23:50:38 +0000 Subject: [PATCH 09/18] Make ci-emscripten.yml match the other wheel jobs --- .github/workflows/ci-emscripten.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-emscripten.yml b/.github/workflows/ci-emscripten.yml index 760eada5..8bb47acc 100644 --- a/.github/workflows/ci-emscripten.yml +++ b/.github/workflows/ci-emscripten.yml @@ -1,24 +1,16 @@ -name: Run Pyodide CI +name: Build Pyodide -on: - pull_request: - workflow_dispatch: - -env: - FORCE_COLOR: 3 - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - # cancel-in-progress: true +on: [push, pull_request] jobs: - build: - runs-on: ubuntu-latest + build_wheels: + name: Build Pyodide wheel + runs-on: ubuntu-22.04 env: # This needs to be kept in sync with pyodide-version in pyproject.toml EMSCRIPTEN_VERSION: 4.0.9 steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@v6.0.2 - name: Set up Emscripten toolchain uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 @@ -31,9 +23,9 @@ jobs: uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 + key: wasm-library-dir-${{ env.EMSCRIPTEN_VERSION }}-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - - name: Build and test Pyodide wheel + - name: Build wheels uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 env: CIBW_PLATFORM: pyodide @@ -45,7 +37,7 @@ jobs: uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 + key: wasm-library-dir-${{ env.EMSCRIPTEN_VERSION }}-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - uses: actions/upload-artifact@v7 with: From a6ef189b5357b1ea0bcc2053a671040f29bb35f5 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 01:01:58 +0000 Subject: [PATCH 10/18] Merge the pyodide CI workflow into the main workflow --- .github/workflows/buildwheel.yml | 114 +++++++++++++++++++++++++--- .github/workflows/ci-emscripten.yml | 45 ----------- pyproject.toml | 11 +-- 3 files changed, 106 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/ci-emscripten.yml diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 2b45a59f..98dad1de 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -4,55 +4,114 @@ on: [push, pull_request] jobs: build_wheels: - name: Build wheels for ${{ matrix.os }} + name: ${{ matrix.name }} runs-on: ${{ matrix.os }} continue-on-error: true strategy: fail-fast: false matrix: - os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2022, windows-11-arm, macos-15-intel, macos-14] + include: + - name: Build manylinux x86-64 wheels + os: ubuntu-22.04 + kind: native + artifact_name: wheels-ubuntu-22.04 + cibw_platform: auto + cibw_build: "*" + - name: Build manylinux arm64 wheels + os: ubuntu-22.04-arm + kind: native + artifact_name: wheels-ubuntu-22.04-arm + cibw_platform: auto + cibw_build: "*" + - name: Build Windows x86-64 wheels + os: windows-2022 + kind: native + artifact_name: wheels-windows-2022 + cibw_platform: auto + cibw_build: "*" + - name: Build Windows arm64 wheels + os: windows-11-arm + kind: native + artifact_name: wheels-windows-11-arm + cibw_platform: auto + cibw_build: "*" + - name: Build macOS x86-64 wheels + os: macos-15-intel + kind: native + artifact_name: wheels-macos-15-intel + cibw_platform: auto + cibw_build: "*" + - name: Build macOS arm64 wheels + os: macos-14 + kind: native + artifact_name: wheels-macos-14 + cibw_platform: auto + cibw_build: "*" + - name: Build Pyodide wheels + os: ubuntu-22.04 + kind: pyodide + artifact_name: wheels-pyodide + emscripten_version: 4.0.9 + cibw_platform: pyodide + cibw_build: cp313-* steps: - uses: actions/checkout@v6.0.2 - - uses: actions/setup-python@v6 + - if: ${{ matrix.kind == 'native' }} + uses: actions/setup-python@v6 with: python-version: '3.13' - - uses: msys2/setup-msys2@v2.30.0 + # -------------- Windows stuff ---------------- # + + - if: ${{ matrix.os == 'windows-2022' }} + uses: msys2/setup-msys2@v2.30.0 with: msystem: ucrt64 update: true - if: ${{ matrix.os == 'windows-2022' }} - - uses: msys2/setup-msys2@v2.30.0 + - if: ${{ matrix.os == 'windows-11-arm' }} + uses: msys2/setup-msys2@v2.30.0 with: msystem: clangarm64 update: true - if: ${{ matrix.os == 'windows-11-arm' }} # Install pkgconfig on Windows from choco rather than from msys and # avoid using the Strawberry one. - - run: choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite - if: ${{ startsWith( matrix.os , 'windows' ) }} + - if: ${{ startsWith( matrix.os , 'windows' ) }} + run: choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite # We have to set this here rather than in the cibuildwheel config # This is probably something to do with \ vs / in paths... - - run: | + - if: ${{ startsWith( matrix.os , 'windows' ) }} + run: | $pkgConfigPath = "${{ github.workspace }}/.local/lib/pkgconfig" $pkgConfigPath = $pkgConfigPath.Replace('\', '/') echo "PKG_CONFIG_PATH=$pkgConfigPath" >> $env:GITHUB_ENV - if: ${{ startsWith( matrix.os , 'windows' ) }} + + # ------------- pyodide ------------- # + + - if: ${{ matrix.kind == 'pyodide' }} + name: Set up Emscripten toolchain + uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 + with: + version: ${{ matrix.emscripten_version }} + actions-cache-folder: emsdk-cache + + # ------------- actual build ------------- # - name: Build wheels uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 env: + CIBW_PLATFORM: ${{ matrix.cibw_platform }} + CIBW_BUILD: ${{ matrix.cibw_build }} # override setting in pyproject.toml to use msys2 instead of msys64 bash 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' }} - uses: actions/upload-artifact@v7 with: - name: wheels-${{ matrix.os }} + name: ${{ matrix.artifact_name }} path: wheelhouse/*.whl build_sdist: @@ -120,6 +179,37 @@ jobs: - run: python -m flint.test --verbose + test_pyodide: + needs: build_wheels + name: Test Pyodide wheel + runs-on: ubuntu-22.04 + env: + PYODIDE_VERSION: 0.28.2 + + steps: + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + + - uses: actions/setup-node@v6 + with: + node-version: '22' + + - run: pip install "pyodide-build==${{ env.PYODIDE_VERSION }}" + - run: pyodide xbuildenv install "${{ env.PYODIDE_VERSION }}" + + - uses: actions/download-artifact@v8 + with: + name: wheels-pyodide + path: wheelhouse + + - run: | + pyodide venv .venv-pyodide + source .venv-pyodide/bin/activate + pip install wheelhouse/*.whl + pip install pytest hypothesis + python -m pytest -svra -p no:cacheprovider --pyargs flint + # On new enough Ubuntu we can build against the system deb. test_pip_flint_deb: name: Build on ${{ matrix.os }} diff --git a/.github/workflows/ci-emscripten.yml b/.github/workflows/ci-emscripten.yml deleted file mode 100644 index 8bb47acc..00000000 --- a/.github/workflows/ci-emscripten.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Build Pyodide - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build Pyodide wheel - runs-on: ubuntu-22.04 - env: - # This needs to be kept in sync with pyodide-version in pyproject.toml - EMSCRIPTEN_VERSION: 4.0.9 - steps: - - uses: actions/checkout@v6.0.2 - - - name: Set up Emscripten toolchain - uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 - with: - version: ${{ env.EMSCRIPTEN_VERSION }} - actions-cache-folder: emsdk-cache - - - name: Restore WASM library directory from cache - id: cache-wasm-library-dir - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ env.EMSCRIPTEN_VERSION }}-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - - - name: Build wheels - uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 - env: - CIBW_PLATFORM: pyodide - # This needs to be kept in sync with pyodide-version in pyproject.toml - CIBW_BUILD: cp313-* - - - name: Persist WASM library directory to cache - if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true' - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}/wasm-library-dir - key: wasm-library-dir-${{ env.EMSCRIPTEN_VERSION }}-${{ hashFiles('pyproject.toml', 'bin/cibw_before_all_pyodide.sh', 'bin/pyodide_build_dependencies.sh', 'bin/build_variables.sh') }}-0 - - - uses: actions/upload-artifact@v7 - with: - name: wheels-pyodide - path: wheelhouse/*.whl diff --git a/pyproject.toml b/pyproject.toml index 2a7da7fa..40e638db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,11 +181,10 @@ repair-wheel-command = [ before-all = "bin/cibw_before_all_pyodide.sh" before-build = "pip install wheel" -# This needs to be kept in sync with EMSCRIPTEN_VERSION and CIBW_BUILD in -# .github.workflows/ci-emscripten.yml. The pyodide version pins both an -# emscripten version and a CPython minor version. Not sure what is a good link -# to see a table of versions but the command pyodide xbuildenv search --all -# shows this. +# This needs to be kept in sync with the Pyodide row in +# .github/workflows/buildwheel.yml. The Pyodide version pins both an +# Emscripten version and a CPython minor version. The command +# `pyodide xbuildenv search --all` shows the compatible combinations. pyodide-version = "0.28.2" # GMP, MPFR, and FLINT are built as static libraries for Pyodide. @@ -201,8 +200,6 @@ repair-wheel-command = [ """, "cp \"{wheel}\" \"{dest_dir}\"", ] -test-command = "python -m pytest -svra -p no:cacheprovider --pyargs flint" -test-requires = ["pytest", "hypothesis"] [tool.cibuildwheel.pyodide.environment] WASM_LIBRARY_DIR = "$(pwd)/wasm-library-dir" From 33f9617f286f56b1c5bf68e5fe228c2fb98b394d Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 01:53:26 +0000 Subject: [PATCH 11/18] Don't pin pyodide-build version --- .github/workflows/buildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 98dad1de..826d52d4 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -195,7 +195,7 @@ jobs: with: node-version: '22' - - run: pip install "pyodide-build==${{ env.PYODIDE_VERSION }}" + - run: pip install pyodide-build - run: pyodide xbuildenv install "${{ env.PYODIDE_VERSION }}" - uses: actions/download-artifact@v8 From e5dc59362ba12aacb0aed1b5ea20a2d0cf26fd5e Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 16:59:41 +0000 Subject: [PATCH 12/18] Use shared libraries for dependencies in pyodide --- bin/pyodide_build_dependencies.sh | 15 +++++++++++++++ pyproject.toml | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/pyodide_build_dependencies.sh b/bin/pyodide_build_dependencies.sh index d58af513..ee6e22f9 100755 --- a/bin/pyodide_build_dependencies.sh +++ b/bin/pyodide_build_dependencies.sh @@ -129,3 +129,18 @@ fi emmake make install cd .. + + +# ----------------Build shared libraries from static archives --------------# + + +emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libgmp.so" \ + -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libgmp.a" -Wl,--no-whole-archive + +emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libmpfr.so" \ + -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libmpfr.a" -Wl,--no-whole-archive \ + -L"$WASM_LIBRARY_DIR/lib" -lgmp + +emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libflint.so" \ + -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libflint.a" -Wl,--no-whole-archive \ + -L"$WASM_LIBRARY_DIR/lib" -lmpfr -lgmp diff --git a/pyproject.toml b/pyproject.toml index 40e638db..4c869699 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,7 +179,7 @@ repair-wheel-command = [ [tool.cibuildwheel.pyodide] before-all = "bin/cibw_before_all_pyodide.sh" -before-build = "pip install wheel" +before-build = "pip install wheel auditwheel_emscripten" # This needs to be kept in sync with the Pyodide row in # .github/workflows/buildwheel.yml. The Pyodide version pins both an @@ -187,7 +187,8 @@ before-build = "pip install wheel" # `pyodide xbuildenv search --all` shows the compatible combinations. pyodide-version = "0.28.2" -# GMP, MPFR, and FLINT are built as static libraries for Pyodide. +# GMP, MPFR, and FLINT are built as shared libraries for Pyodide and bundled +# into the wheel. repair-wheel-command = [ """python bin/cibw_repair_wheel_licenses.py "{wheel}" \ --license LGPL-3.0-or-later \ @@ -198,7 +199,7 @@ repair-wheel-command = [ --license-file 'wasm-library-dir/src/flint-*/COPYING:python-flint.libs/flint-*/COPYING' \ --license-file 'wasm-library-dir/src/flint-*/COPYING.LESSER:python-flint.libs/flint-*/COPYING.LESSER' \ """, -"cp \"{wheel}\" \"{dest_dir}\"", +"pyodide auditwheel repair --libdir wasm-library-dir --output-dir {dest_dir} {wheel}", ] [tool.cibuildwheel.pyodide.environment] From 57f4aec9e898acb76aa05efac98a615edb3393c5 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 17:43:01 +0000 Subject: [PATCH 13/18] Don't strip the libraries --- bin/pyodide_build_dependencies.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/pyodide_build_dependencies.sh b/bin/pyodide_build_dependencies.sh index ee6e22f9..d8b776e8 100755 --- a/bin/pyodide_build_dependencies.sh +++ b/bin/pyodide_build_dependencies.sh @@ -134,13 +134,13 @@ cd .. # ----------------Build shared libraries from static archives --------------# -emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libgmp.so" \ +emcc -shared -sSIDE_MODULE=1 -o "$WASM_LIBRARY_DIR/lib/libgmp.so" \ -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libgmp.a" -Wl,--no-whole-archive -emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libmpfr.so" \ +emcc -shared -sSIDE_MODULE=1 -o "$WASM_LIBRARY_DIR/lib/libmpfr.so" \ -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libmpfr.a" -Wl,--no-whole-archive \ -L"$WASM_LIBRARY_DIR/lib" -lgmp -emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libflint.so" \ +emcc -shared -sSIDE_MODULE=1 -o "$WASM_LIBRARY_DIR/lib/libflint.so" \ -Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libflint.a" -Wl,--no-whole-archive \ -L"$WASM_LIBRARY_DIR/lib" -lmpfr -lgmp From c8b7323495570a120a5a2361e2d10281c46bb32e Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 19:10:24 +0000 Subject: [PATCH 14/18] Don't upload pyodide wheels to PyPI --- .github/workflows/buildwheel.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 826d52d4..634e9d5a 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -428,7 +428,11 @@ jobs: merge-multiple: true - name: Copy the PyPI files into dist - run: mkdir dist && cp wheelhouse/*.whl wheelhouse/*.tar.gz dist + # pyodide wheels cannot be uploaded to PyPI + run: | + mkdir dist + rm wheelhouse/*pyodide*.whl + cp wheelhouse/*.whl wheelhouse/*.tar.gz dist - name: Publish package on PyPI # It is recommended to pin a commit hash here for security but it From a79fa74ddb1958958c001dc1ec958c0a15b293d5 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 22:59:58 +0000 Subject: [PATCH 15/18] Apply pyodide emscripten patches --- .github/workflows/buildwheel.yml | 17 +++++++++++++++-- bin/cibw_before_build_pyodide.sh | 12 ++++++++++++ pyproject.toml | 12 +++--------- 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100755 bin/cibw_before_build_pyodide.sh diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 634e9d5a..8842634a 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -2,6 +2,9 @@ name: Build on: [push, pull_request] +env: + PYODIDE_VERSION: 0.28.2 + jobs: build_wheels: name: ${{ matrix.name }} @@ -99,6 +102,16 @@ jobs: version: ${{ matrix.emscripten_version }} actions-cache-folder: emsdk-cache + - if: ${{ matrix.kind == 'pyodide' }} + name: Check out Emscripten patches for Pyodide + uses: actions/checkout@v6.0.2 + with: + repository: pyodide/pyodide + ref: ${{ env.PYODIDE_VERSION }} + path: pyodide-patches + sparse-checkout: | + emsdk/patches/ + # ------------- actual build ------------- # - name: Build wheels @@ -106,6 +119,8 @@ jobs: env: CIBW_PLATFORM: ${{ matrix.cibw_platform }} CIBW_BUILD: ${{ matrix.cibw_build }} + CIBW_PYODIDE_VERSION: ${{ env.PYODIDE_VERSION }} + PYODIDE_EMSCRIPTEN_VERSION: ${{ matrix.kind == 'pyodide' && matrix.emscripten_version || '' }} # override setting in pyproject.toml to use msys2 instead of msys64 bash 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' }} @@ -183,8 +198,6 @@ jobs: needs: build_wheels name: Test Pyodide wheel runs-on: ubuntu-22.04 - env: - PYODIDE_VERSION: 0.28.2 steps: - uses: actions/setup-python@v6 diff --git a/bin/cibw_before_build_pyodide.sh b/bin/cibw_before_build_pyodide.sh new file mode 100755 index 00000000..847a07ac --- /dev/null +++ b/bin/cibw_before_build_pyodide.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -euo pipefail + +python -m pip install wheel auditwheel_emscripten + +EMSCRIPTEN_DIR="$HOME/.cache/cibuildwheel/emsdk-$PYODIDE_EMSCRIPTEN_VERSION/emsdk-$PYODIDE_EMSCRIPTEN_VERSION/upstream/emscripten" + +for patch_file in pyodide-patches/emsdk/patches/*.patch; do + echo "Applying Pyodide Emscripten patch $(basename "$patch_file")" + patch -p1 --verbose -d "$EMSCRIPTEN_DIR" < "$patch_file" +done diff --git a/pyproject.toml b/pyproject.toml index 4c869699..17be866a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,16 +179,10 @@ repair-wheel-command = [ [tool.cibuildwheel.pyodide] before-all = "bin/cibw_before_all_pyodide.sh" -before-build = "pip install wheel auditwheel_emscripten" +before-build = "bin/cibw_before_build_pyodide.sh" +# The pyodide version is set in .github/workflows/buildwheel.yml as +# CIBW_PYODIDE_VERSION because it is needed also for other things there. -# This needs to be kept in sync with the Pyodide row in -# .github/workflows/buildwheel.yml. The Pyodide version pins both an -# Emscripten version and a CPython minor version. The command -# `pyodide xbuildenv search --all` shows the compatible combinations. -pyodide-version = "0.28.2" - -# GMP, MPFR, and FLINT are built as shared libraries for Pyodide and bundled -# into the wheel. repair-wheel-command = [ """python bin/cibw_repair_wheel_licenses.py "{wheel}" \ --license LGPL-3.0-or-later \ From 1e1a88321111240eaf66fd1bff21c35590f9d032 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 23:03:01 +0000 Subject: [PATCH 16/18] Use pyodide's fork of emsdk --- .github/workflows/buildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 8842634a..af2275e3 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -97,7 +97,7 @@ jobs: - if: ${{ matrix.kind == 'pyodide' }} name: Set up Emscripten toolchain - uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 + uses: pyodide/setup-emsdk@ca2dd8aef8c2a0e11743c5c36f0b430ddb694b5c # v15 with: version: ${{ matrix.emscripten_version }} actions-cache-folder: emsdk-cache From 5b9460d3c0811f662fe60ec5ecb22a2c557af55d Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 23:35:44 +0000 Subject: [PATCH 17/18] Bump pyodide version 0.28.2 -> 0.29.3 --- .github/workflows/buildwheel.yml | 18 ++++++++++-------- pyproject.toml | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index af2275e3..e921dc14 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -3,7 +3,12 @@ name: Build on: [push, pull_request] env: - PYODIDE_VERSION: 0.28.2 + # These four values need to be kept in sync. Each pyodide version pins an + # emscripten version and a CPython version. + PYODIDE_VERSION: '0.29.3' + PYODIDE_EMSCRIPTEN_VERSION: '4.0.9' + PYODIDE_PYTHON_VERSION: '3.13' + PYODIDE_CIBW_BUILD: 'cp313-*' jobs: build_wheels: @@ -54,9 +59,7 @@ jobs: os: ubuntu-22.04 kind: pyodide artifact_name: wheels-pyodide - emscripten_version: 4.0.9 cibw_platform: pyodide - cibw_build: cp313-* steps: - uses: actions/checkout@v6.0.2 @@ -99,7 +102,7 @@ jobs: name: Set up Emscripten toolchain uses: pyodide/setup-emsdk@ca2dd8aef8c2a0e11743c5c36f0b430ddb694b5c # v15 with: - version: ${{ matrix.emscripten_version }} + version: ${{ env.PYODIDE_EMSCRIPTEN_VERSION }} actions-cache-folder: emsdk-cache - if: ${{ matrix.kind == 'pyodide' }} @@ -118,9 +121,8 @@ jobs: uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 env: CIBW_PLATFORM: ${{ matrix.cibw_platform }} - CIBW_BUILD: ${{ matrix.cibw_build }} + CIBW_BUILD: ${{ matrix.kind == 'pyodide' && env.PYODIDE_CIBW_BUILD || matrix.cibw_build }} CIBW_PYODIDE_VERSION: ${{ env.PYODIDE_VERSION }} - PYODIDE_EMSCRIPTEN_VERSION: ${{ matrix.kind == 'pyodide' && matrix.emscripten_version || '' }} # override setting in pyproject.toml to use msys2 instead of msys64 bash 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' }} @@ -138,7 +140,7 @@ jobs: - uses: actions/setup-python@v6 with: - python-version: '3.13' + python-version: ${{ env.PYODIDE_PYTHON_VERSION }} - run: bin/install_latest_flint_ubuntu.sh - run: pip install build @@ -202,7 +204,7 @@ jobs: steps: - uses: actions/setup-python@v6 with: - python-version: '3.13' + python-version: ${{ env.PYODIDE_PYTHON_VERSION }} - uses: actions/setup-node@v6 with: diff --git a/pyproject.toml b/pyproject.toml index 17be866a..2745e333 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -178,10 +178,9 @@ repair-wheel-command = [ ] [tool.cibuildwheel.pyodide] +# pyodide version is set in .github/workflows/buildwheel.yml as PYODIDE_VERSION before-all = "bin/cibw_before_all_pyodide.sh" before-build = "bin/cibw_before_build_pyodide.sh" -# The pyodide version is set in .github/workflows/buildwheel.yml as -# CIBW_PYODIDE_VERSION because it is needed also for other things there. repair-wheel-command = [ """python bin/cibw_repair_wheel_licenses.py "{wheel}" \ From 877a6a52077f1c95b178ec5d778090cacc26834f Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Tue, 24 Mar 2026 23:44:16 +0000 Subject: [PATCH 18/18] Remove dep_py from the meson.build files --- meson.build | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/meson.build b/meson.build index e126d3c6..fbabce65 100644 --- a/meson.build +++ b/meson.build @@ -21,13 +21,6 @@ cython_lower = '>=3.0.11' cython_upper = '<3.3' py = import('python').find_installation(pure: false) -if meson.is_cross_build() and host_machine.system() == 'emscripten' - # Avoid picking up the runner's host python.pc via pkg-config. - # For Pyodide, use the interpreter sysconfig data from pyodide-build instead. - dep_py = py.dependency(method: 'system') -else - dep_py = py.dependency() -endif cc = meson.get_compiler('c') cy = meson.get_compiler('cython') @@ -85,7 +78,7 @@ else have_acb_theta = true endif -pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep] +pyflint_deps = [gmp_dep, mpfr_dep, flint_dep] add_project_arguments( '-X', 'embedsignature=True',