Skip to content

Commit cb36e10

Browse files
committed
Add notes for pyodide building process
1 parent 7ca44b5 commit cb36e10

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

pyodide/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
There are two ways to build pyodide ifcopenshell Python wrapper wheel.
3+
4+
1. Using pyodide build system (`build_pyodide.yml` does it):
5+
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
8+
- create `packages/ifcopenshell` folder that will be used by pyodide build system
9+
- from `IfcOpenShell` move building recipe `pyodide/meta.yaml` to `packages/ifcopenshell`
10+
- run `pyodide build-recipes ifcopenshell --install`, it will
11+
- execute `meta.yaml` recipe - it will:
12+
- copy IfcOpenShell source to build folder `packages/ifcopenhell/build/ifcopenshell-0.8.0`
13+
- build ifcopenshell and its dependencies
14+
- note that rerunning `pyodide build-recipes` will remove previous build folder and rebuild all dependencies.
15+
The way to avoid it, if build fails, is to use `pyodide build-recipes-no-deps ifcopenshell --continue` instead.
16+
- run `pyodide/setup.py` in `IfcOpenShell` root, producing a wheel in `IfcOpenShell/dist`
17+
- copy that wheel to `packages/ifcopenshell/dist`
18+
- `--install` it to current build envrionment
19+
- copy the wheel next to `dist` folder (in root directory, next to `packages`)
20+
- add wheel to `dist/pyodide-lock.json`
21+
22+
2. Build it outside of pyodide system.
23+
24+
Building inside pyodide build system should be preferred, option to build it outside is useful for debugging purposes,
25+
since it's pure cmake without any additional moving parts.
26+
27+
- setup pyodide environment in `pyodide_root` folder, see above
28+
- clone IfcOpenShell repo next to it to `IfcOpenShell` folder
29+
- setup debug build environment using `source pyodide/debug_build_env.sh /path/to/pyodide_root`
30+
- run `python nix/build-all.py -wasm -py-313` in `IfcOpenShell`
31+
- it will produce Python package in `IfcOpenShell/ifcopenshell`
32+
- move `IfcOpenShell/pyodide/setup.py` to `IfcOpenShell` root
33+
- run `pyodide build`
34+
- it will produce a wheel in `IfcOpenShell/dist`

pyodide/debug_build_env.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
if [ $# -ne 1 ]; then
3+
echo "Usage: $0 <pyodide_root>"
4+
exit 1
5+
fi
6+
export PYODIDE_ROOT=$(readlink -f "$1")
7+
export PATH="$PYODIDE_ROOT/emsdk/emsdk:$PYODIDE_ROOT/emsdk/emsdk/node/22.16.0_64bit/bin:$PYODIDE_ROOT/emsdk/emsdk/upstream/emscripten:$PATH"
8+
# build-all.py vars.
9+
export WASM_PYTHON_PATH="$PYODIDE_ROOT/cpython/installs/python-3.13.2"
10+
export WASM_TOOLCHAIN_FILE="$PYODIDE_ROOT/pyodide-build/pyodide_build/tools/cmake/Modules/Platform/Emscripten.cmake"

pyodide/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package:
33
version: 0.8.0
44

55
source:
6+
# meta.yaml is placed as `packages/ifcopenshell/meta.yaml`.
67
path: ../../IfcOpenShell
78

89
build:

0 commit comments

Comments
 (0)