Skip to content

Commit 03ce636

Browse files
authored
Fix compilation with emscripten (#294)
* Fixes to C code for compilation with emscripten * Added emscripten CI build * Don't refer to non-existent all extra * Added hashes to GA config
1 parent 205fdc4 commit 03ce636

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# GitHub Actions workflow for testing Emscripten/WebAssembly build via Pyodide
2+
3+
name: Emscripten
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
11+
jobs:
12+
build-wasm:
13+
name: Build for WebAssembly
14+
runs-on: ubuntu-22.04
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install pyodide-build
28+
run: pip install pyodide-build>=0.29.2
29+
30+
- name: Get Emscripten version
31+
run: echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
32+
33+
- name: Set up Emscripten SDK
34+
uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
35+
with:
36+
version: ${{ env.EMSCRIPTEN_VERSION }}
37+
38+
- name: Build wheel for Pyodide
39+
run: pyodide build

cextern/astrometry.net/qsort_reentrant.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#ifdef _MSC_VER
3838
# include <stdio.h>
3939
#else
40-
#if __sun
40+
#if defined(__sun) || defined(__EMSCRIPTEN__)
4141
# include <stdio.h>
4242
#else
4343
# include <sys/cdefs.h>

cextern/numpy/ieee754.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static void _npy_set_floatstatus_invalid(void)
7070
fp_raise_xcp(FP_INVALID);
7171
}
7272

73-
#elif defined(_MSC_VER) || (defined(__osf__) && defined(__alpha))
73+
#elif defined(_MSC_VER) || (defined(__osf__) && defined(__alpha)) || defined(__EMSCRIPTEN__)
7474

7575
/*
7676
* By using a volatile floating point value,
@@ -80,6 +80,10 @@ static void _npy_set_floatstatus_invalid(void)
8080
* We shouldn't write multiple values to a single
8181
* global here, because that would cause
8282
* a race condition.
83+
*
84+
* Note: Emscripten is included here because its fenv.h implementation
85+
* provides stub functions that don't actually manipulate floating-point
86+
* state (WebAssembly has limited access to hardware exception mechanisms).
8387
*/
8488
static volatile double _npy_floatstatus_x, _npy_floatstatus_inf;
8589

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ deps =
6060
# The following indicates which extras_require from setup.cfg will be installed
6161
extras =
6262
test
63-
alldeps: all
6463

6564
install_command =
6665
!devdeps: python -I -m pip install

0 commit comments

Comments
 (0)