Skip to content

Commit 32da025

Browse files
ci: add pyodide test (#84)
* ci: add pyodide test Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * WIP: fix pyodide Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: specify test location Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * WIP: try printing wheel contents Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update CMakeLists.txt * Update CMakeLists.txt * Update pyproject.toml * Update enscripten.yaml * style: pre-commit fixes * Update CMakeLists.txt --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f624a7b commit 32da025

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

.github/workflows/enscripten.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: WASM
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-wasm-emscripten:
15+
name: Pyodide
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: true
21+
fetch-depth: 0
22+
23+
- uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.11"
26+
27+
- name: Install pyodide-build
28+
run: pip install pyodide-build==0.23.1
29+
30+
- name: Compute emsdk version
31+
id: compute-emsdk-version
32+
run: |
33+
pyodide xbuildenv install --download
34+
EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
35+
echo "emsdk-version=$EMSCRIPTEN_VERSION" >> $GITHUB_OUTPUT
36+
37+
- uses: mymindstorm/setup-emsdk@v12
38+
with:
39+
version: ${{ steps.compute-emsdk-version.outputs.emsdk-version }}
40+
actions-cache-folder: emsdk-cache
41+
42+
# A future version of pyodide may switch to -fwasm-exceptions
43+
- name: Build
44+
run: CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build
45+
46+
- uses: actions/upload-artifact@v3
47+
with:
48+
path: dist/*.whl
49+
50+
- uses: actions/setup-node@v3
51+
with:
52+
node-version: 18
53+
54+
- name: Set up Pyodide virtual environment
55+
run: |
56+
pyodide venv .venv-pyodide
57+
.venv-pyodide/bin/pip install $(echo -n dist/*.whl)[test]
58+
59+
- name: Test
60+
run: .venv-pyodide/bin/pytest

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ cmake_minimum_required(VERSION 3.15...3.26)
22

33
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
44

5+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
56
find_package(pybind11 CONFIG REQUIRED)
67

7-
pybind11_add_module(_core MODULE src/main.cpp)
8+
python_add_library(_core MODULE src/main.cpp WITH_SOABI)
9+
target_link_libraries(_core PRIVATE pybind11::headers)
810
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
911

1012
install(TARGETS _core DESTINATION scikit_build_example)

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["scikit-build-core>=0.2.1", "pybind11"]
2+
requires = ["scikit-build-core>=0.3.3", "pybind11"]
33
build-backend = "scikit_build_core.build"
44

55

@@ -31,6 +31,14 @@ test = ["pytest"]
3131
wheel.expand-macos-universal-tags = true
3232

3333

34+
[tool.pytest.ini_options]
35+
minversion = "6.0"
36+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
37+
xfail_strict = true
38+
filterwarnings = ["error"]
39+
testpaths = ["tests"]
40+
41+
3442
[tool.cibuildwheel]
3543
test-command = "pytest {project}/tests"
3644
test-extras = ["test"]

0 commit comments

Comments
 (0)