-
Notifications
You must be signed in to change notification settings - Fork 29
159 lines (133 loc) · 5.49 KB
/
ci-emscripten.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Run Pyodide CI
on:
pull_request:
workflow_dispatch:
env:
FORCE_COLOR: 3
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
PYODIDE_VERSION: 0.27.3
# PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION.
# The appropriate versions can be found in the Pyodide repodata.json
# "info" field, or in Makefile.envs:
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
PYTHON_VERSION: 3.12 # any 3.12.x version works
EMSCRIPTEN_VERSION: 3.1.58
NODE_VERSION: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
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@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install pyodide-build
run: pip install pyodide-build
- name: Restore WASM library directory from cache
id: cache-wasm-library-dir
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ${{ github.workspace }}/wasm-library-dir
key: wasm-library-dir-${{ hashFiles('.github/workflows/ci-emscripten.yml') }}
- name: Build libgmp
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
env:
CFLAGS: "-fPIC"
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
run: |
curl -L https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz -o gmp-6.3.0.tar.xz
tar -xf gmp-6.3.0.tar.xz
cd gmp-6.3.0
emconfigure ./configure \
--disable-dependency-tracking \
--host none \
--disable-shared \
--enable-static \
--enable-cxx \
--prefix=${{ env.WASM_LIBRARY_DIR }}
emmake make -j $(nproc)
emmake make install
- name: Build libmpfr
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
env:
CFLAGS: "-fPIC"
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
run: |
curl -L https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz -o mpfr-4.2.1.tar.xz
tar -xf mpfr-4.2.1.tar.xz
cd mpfr-4.2.1
emconfigure ./configure \
--disable-dependency-tracking \
--disable-shared \
--with-gmp="${{ env.WASM_LIBRARY_DIR }}" \
--prefix=${{ env.WASM_LIBRARY_DIR }}
emmake make -j $(nproc)
emmake make install
- name: Check out flint
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: flintlib/flint
path: flint
- name: Build flint
if: steps.cache-wasm-library-dir.outputs.cache-hit != 'true'
env:
CFLAGS: "-fPIC"
WASM_LIBRARY_DIR: ${{ github.workspace }}/wasm-library-dir
working-directory: flint
run: |
./bootstrap.sh
emconfigure ./configure \
--disable-dependency-tracking \
--disable-shared \
--prefix=${{ env.WASM_LIBRARY_DIR }} \
--with-gmp=${{ env.WASM_LIBRARY_DIR }} \
--with-mpfr=${{ env.WASM_LIBRARY_DIR }} \
--host=wasm32-unknown-emscripten \
--disable-assembly \
--disable-pthread
emmake make -j $(nproc)
emmake make install
- name: Persist WASM library directory to cache
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ${{ github.workspace }}/wasm-library-dir
key: wasm-library-dir-${{ hashFiles('.github/workflows/ci-emscripten.yml') }}
- 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
pyodide build -C "setup-args=-Dflint_version_check=false"
- name: Set up Pyodide virtual environment and test python-flint
run: |
pyodide xbuildenv install ${{ env.PYODIDE_VERSION }}
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