diff --git a/pyodide/README.md b/pyodide/README.md index c7ce24321d..fb2fde8253 100644 --- a/pyodide/README.md +++ b/pyodide/README.md @@ -28,8 +28,11 @@ since it's pure cmake without any additional moving parts. - clone IfcOpenShell repo next to it to `IfcOpenShell` folder - run `python nix/build-all.py -wasm -py-313` in `IfcOpenShell` - it will produce Python package in `IfcOpenShell/ifcopenshell` -- run `pyodide build` - - it will produce a wheel in `IfcOpenShell/dist` +- run `python pyodide/build-all-pack-wheel-local.py`, it will + - clean up previous wheels + - run `pyodide build` + - prepare standalone and modular wheels + - produce final wheels in `IfcOpenShell/dist` and `IfcOpenshell/dist-modular` - testing: - ensure you're in pyodide environment - `cd IfcOpenshell/pyodide` diff --git a/pyodide/build-all-pack-wheel-local.py b/pyodide/build-all-pack-wheel-local.py new file mode 100755 index 0000000000..f85268b1fa --- /dev/null +++ b/pyodide/build-all-pack-wheel-local.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +"""Intended to be run after nix/build-all.py has finished the wasm build.""" +import shutil +import subprocess +from pathlib import Path + + +def get_repo_root() -> Path: + output = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True) + return Path(output.strip()) + + +def run(cmd: list[str], **kwargs) -> None: + print("$", " ".join(cmd)) + subprocess.check_call(cmd, **kwargs) + + +def main() -> None: + repo_root = get_repo_root() + + shutil.rmtree(repo_root / "dist", ignore_errors=True) + shutil.rmtree(repo_root / "dist_modular", ignore_errors=True) + run(["pyodide", "build"], cwd=repo_root) + shutil.rmtree(repo_root / "ifcopenshell", ignore_errors=True) + (repo_root / "setup.py").unlink(missing_ok=True) + run(["git", "restore", "pyproject.toml"], cwd=repo_root) + + wheel = next((repo_root / "dist").glob("ifcopenshell-*.whl")) + + run(["uv", "run", "pyodide/order_pyodide_wheel_shared_objects.py", str(wheel)], cwd=repo_root) + run( + ["uv", "run", "pyodide/split_pyodide_ifcopenshell_wheel.py", str(wheel), "dist-modular/"], + cwd=repo_root, + ) + + +if __name__ == "__main__": + main()