8000 Merge pull request #26570 from agriyakhetarpal/cibuildwheel-pyodide · numpy/numpy@89b6820 · GitHub
[go: up one dir, main page]

Skip to content

Commit 89b6820

Browse files
authored
Merge pull request #26570 from agriyakhetarpal/cibuildwheel-pyodide
CI, BLD: Use `cibuildwheel` to build WASM NumPy wheels
2 parents 9c323c3 + ad58c55 commit 89b6820

File tree

2 files changed

+22
-71
lines changed

2 files changed

+22
-71
lines changed

.github/workflows/emscripten.yml

Lines changed: 12 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ on:
66
- main
77
- maintenance/**
88
# Note: this workflow gets triggered on the same schedule as the
9-
# wheels.yml workflow, with the exception that this workflow runs
10-
# the test suite for the Pyodide wheel too, prior to uploading it.
11-
#
12-
# Run on schedule to upload to Anaconda.org
9+
# wheels.yml workflow to upload WASM wheels to Anaconda.org.
1310
schedule:
1411
# ┌───────────── minute (0 - 59)
1512
# │ ┌───────────── hour (0 - 23)
@@ -36,86 +33,30 @@ concurrency:
3633
cancel-in-progress: true
3734

3835
permissions:
39-
contents: read # to fetch code (actions/checkout)
36+
contents: read # to fetch code (actions/checkout)
4037

4138
jobs:
4239
build-wasm-emscripten:
4340
name: Build NumPy distribution for Pyodide
4441
runs-on: ubuntu-22.04
4542
# To enable this workflow on a fork, comment out:
4643
if: github.repository == 'numpy/numpy'
47-
env:
48-
PYODIDE_VERSION: 0.26.0
49-
# PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION.
50-
# The appropriate versions can be found in the Pyodide repodata.json
51-
# "info" field, or in Makefile.envs:
52-
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
53-
PYTHON_VERSION: 3.12.1
54-
EMSCRIPTEN_VERSION: 3.1.58
55-
NODE_VERSION: 18
5644
steps:
5745
- name: Checkout NumPy
58-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
46+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5947
with:
6048
submodules: recursive
61-
# This input shall fetch tags without the need to fetch the
62-
# entire VCS history, see https://github.com/actions/checkout#usage
6349
fetch-tags: true
6450

65-
- name: Set up Python ${{ env.PYTHON_VERSION }}
66-
id: setup-python
67-
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
68-
with:
69-
python-version: ${{ env.PYTHON_VERSION }}
51+
- uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # v2.20.0
52+
env:
53+
CIBW_PLATFORM: pyodide
7054

71-
- name: Set up Emscripten toolchain
72-
uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
55+
- name: Upload wheel artifact(s)
56+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
7357
with:
74-
version: ${{ env.EMSCRIPTEN_VERSION }}
75-
actions-cache-folder: emsdk-cache
76-
77-
- name: Install pyodide-build
78-
run: pip install pyodide-build==${{ env.PYODIDE_VERSION }}
79-
80-
- name: Find installation for pyodide-build
81-
shell: python
82-
run: |
83-
import os
84-
import pyodide_build
85-
from pathlib import Path
86-
87-
pyodide_build_path = Path(pyodide_build.__file__).parent
88-
89-
env_file = os.getenv('GITHUB_ENV')
90-
91-
with open(env_file, "a") as myfile:
92-
myfile.write(f"PYODIDE_BUILD_PATH={pyodide_build_path}\n")
93-
94-
- name: Build NumPy for Pyodide
95-
run: |
96-
pyodide build \
97-
-Cbuild-dir=build \
98-
-Csetup-args="--cross-file=$PWD/tools/ci/emscripten/emscripten.meson.cross" \
99-
-Csetup-args="-Dblas=none" \
100-
-Csetup-args="-Dlapack=none"
101-
102-
- name: Set up Node.js
103-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
104-
with:
105-
node-version: ${{ env.NODE_VERSION }}
106-
107-
- name: Set up Pyodide virtual environment
108-
run: |
109-
pyodide venv .venv-pyodide
110-
source .venv-pyodide/bin/activate
111-
pip install dist/*.whl
112-
pip install -r requirements/emscripten_test_requirements.txt
113-
114-
- name: Test NumPy for Pyodide
115-
run: |
116-
source .venv-pyodide/bin/activate
117-
cd ..
118-
pytest --pyargs numpy -m "not slow"
58+
name: cp312-pyodide_wasm32
59+
path: ./wheelhouse/*.whl
11960

12061
# Push to https://anaconda.org/scientific-python-nightly-wheels/numpy
12162
# WARNING: this job will overwrite any existing WASM wheels.
@@ -124,7 +65,7 @@ jobs:
12465
(github.repository == 'numpy/numpy') &&
12566
(github.event_name == 'workflow_dispatch' && github.event.inputs.push_wheels == 'true') ||
12667
(github.event_name == 'schedule')
127-
uses: scientific-python/upload-nightly-action@b67d7fcc0396e1128a474d1ab2b48aa94680f9fc # v0.5.0
68+
uses: scientific-python/upload-nightly-action@b67d7fcc0396e1128a474d1ab2b48aa94680f9fc # v0.5.0
12869
with:
129-
artifacts_path: dist/
70+
artifacts_path: wheelhouse/
13071
anaconda_nightly_upload_token: ${{ secrets.NUMPY_NIGHTLY_UPLOAD_TOKEN }}

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ manylinux-x86_64-image = "manylinux2014"
151151
manylinux-aarch64-image = "manylinux2014"
152152
musllinux-x86_64-image = "musllinux_1_1"
153153

154+
[tool.cibuildwheel.pyodide]
155+
config-settings = "build-dir=build setup-args=--cross-file=$PWD/tools/ci/emscripten/emscripten.meson.cross setup-args=-Dblas=none setup-args=-Dlapack=none"
156+
154157
[tool.cibuildwheel.linux.environment]
155158
# RUNNER_OS is a GitHub Actions specific env var; define it here so it works on Cirrus CI too
156159
RUNNER_OS="Linux"
@@ -180,6 +183,13 @@ select = "*-win32"
180183
config-settings = "setup-args=--vsenv setup-args=-Dallow-noblas=true build-dir=build"
181184
repair-wheel-command = ""
182185

186+
[[tool.cibuildwheel.overrides]]
187+
select = "*pyodide*"
188+
before-test = "pip install -r {project}/requirements/emscripten_test_requirements.txt"
189+
# Pyodide ensures that the wheels are already repaired by auditwheel-emscripten
190+
repair-wheel-command = ""
191+
test-command = "python -m pytest --pyargs numpy -m 'not slow'"
192+
183193
[tool.meson-python]
184194
meson = 'vendored-meson/meson/meson.py'
185195

0 commit comments

Comments
 (0)
0