Skip to content

Commit c27a995

Browse files
committed
build_pyodide - use prebuilt pyodide build env
1 parent 5b4c54a commit c27a995

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

.github/workflows/build_pyodide.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ jobs:
1414
submodules: recursive
1515
path: IfcOpenShell
1616

17-
- name: Checkout Pyodide
18-
uses: actions/checkout@v3
19-
with:
20-
submodules: recursive
21-
repository: pyodide/pyodide
22-
ref: '0.28.0a3'
23-
token: ${{ secrets.BUILD_REPO_TOKEN }}
24-
path: pyodide
25-
2617
- name: Checkout Build Repository
2718
uses: actions/checkout@v3
2819
with:
@@ -39,12 +30,9 @@ jobs:
3930
4031
- name: Build
4132
run: |
42-
VERSION=`cat IfcOpenShell/VERSION`
43-
sed -i s/0.8.0/$VERSION/g IfcOpenShell/pyodide/meta.yaml
44-
sed -i s/--tty// pyodide/run_docker
45-
pyodide/run_docker IfcOpenShell/pyodide/build_pyodide.sh
33+
./IfcOpenShell/pyodide/build_pyodide.sh
4634
FILE=`echo dist/ifcopenshell-*.whl`
47-
NEW_FILE=`echo $FILE | sed "s/$VERSION/$VERSION+${GITHUB_SHA:0:7}/"`
35+
NEW_FILE=`echo $FILE | sed "s/-/+${GITHUB_SHA:0:7}-/2"`
4836
mv $FILE $NEW_FILE
4937
5038
- name: Upload Build Logs

pyodide/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ There are two ways to build pyodide ifcopenshell Python wrapper wheel.
33

44
1. Using pyodide build system (`build_pyodide.yml` does it):
55

6-
- setup pyodide environment in `pyodide_root` folder - either by using image or build it from source - see https://pyodide.org/en/stable/development/building-from-sources.html
7-
- clone IfcOpenShell repo next to it to `IfcOpenShell` folder
6+
- install prebuilt pyodide build and emscripten environment (see `build_pyodide.sh`)
7+
- clone IfcOpenShell to `IfcOpenShell` folder
88
- create `packages/ifcopenshell` folder that will be used by pyodide build system
99
- from `IfcOpenShell` move building recipe `pyodide/meta.yaml` to `packages/ifcopenshell`
1010
- run `pyodide build-recipes ifcopenshell --install`, it will
@@ -19,12 +19,12 @@ There are two ways to build pyodide ifcopenshell Python wrapper wheel.
1919
- copy the wheel next to `dist` folder (in root directory, next to `packages`)
2020
- add wheel to `dist/pyodide-lock.json`
2121

22-
2. Build it outside of pyodide system.
22+
2. Build it outside of pyodide build system.
2323

2424
Building inside pyodide build system should be preferred, option to build it outside is useful for debugging purposes,
2525
since it's pure cmake without any additional moving parts.
2626

27-
- setup pyodide environment in `pyodide_root` folder, see above
27+
- setup pyodide environment, see above
2828
- clone IfcOpenShell repo next to it to `IfcOpenShell` folder
2929
- setup debug build environment using `source pyodide/debug_build_env.sh /path/to/pyodide_root`
3030
- run `python nix/build-all.py -wasm -py-313` in `IfcOpenShell`

pyodide/build_pyodide.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
#!/usr/bin/bash
2-
set -e
3-
cd pyodide
4-
make
5-
cd ..
2+
set -ex
3+
4+
# Install uv.
5+
curl -LsSf https://astral.sh/uv/install.sh | sh
6+
uv venv --python 3.13
7+
source .venv/bin/activate
8+
9+
# Install pyodide cross build environment.
10+
# Instructions: https://pyodide.org/en/stable/development/building-packages.html
11+
uv pip install pyodide-build
12+
# `uv run` is required, so xbuildenv would skip using `pip`.
13+
uv run pyodide xbuildenv install
14+
15+
# Emscripten doesn't come with xbuildenv.
16+
git clone https://github.com/emscripten-core/emsdk
17+
pushd emsdk
18+
PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
19+
./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION}
20+
./emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION}
21+
source emsdk_env.sh
22+
which emcc
23+
popd
24+
625
mkdir -p packages/ifcopenshell
26+
VERSION=`cat IfcOpenShell/VERSION`
727
cp IfcOpenShell/pyodide/meta.yaml packages/ifcopenshell
8-
# Required, otherwise pyodide will create new temp pyodide environment.
9-
export PYODIDE_ROOT=/src/pyodide
10-
# Ensure emsdk tools are in PATH.
11-
export PATH=$PYODIDE_ROOT/emsdk/emsdk:$PYODIDE_ROOT/emsdk/emsdk/node/22.16.0_64bit/bin:$PYODIDE_ROOT/emsdk/emsdk/upstream/emscripten:$PATH
28+
sed -i s/0.8.0/$VERSION/g packages/ifcopenshell/meta.yaml
29+
1230
# Use custom build ifcopenshell directory in build-all to make caching simpler
1331
# Otherwise pyodide build path typically includes package version, so cached cmake configs might break.
14-
export BUILD_DIR=/src/ifcopenshell_build
32+
export BUILD_DIR=`readlink -f ifcopenshell_build`
33+
1534
# Use build-recipes-no-deps first, so logs would be printed to stdout.
1635
pyodide build-recipes-no-deps ifcopenshell
1736
pyodide build-recipes ifcopenshell --install

0 commit comments

Comments
 (0)