From 1f8c12a4c8fdc786de75f59345658398d8d4ec1d Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 28 Oct 2025 13:02:19 +0500 Subject: [PATCH] build_pyodide - test wasm wheel working --- .github/workflows/build_pyodide.yml | 13 +++++++++++++ pyodide/test/test_wheel.py | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 pyodide/test/test_wheel.py diff --git a/.github/workflows/build_pyodide.yml b/.github/workflows/build_pyodide.yml index 03ca7a987c..f42b7a9846 100644 --- a/.github/workflows/build_pyodide.yml +++ b/.github/workflows/build_pyodide.yml @@ -49,6 +49,19 @@ jobs: ifcopenshell_build/*/*/logs/*.log retention-days: 30 + - name: Run wheel tests + run: | + cp -r IfcOpenShell/pyodide/test test + # venv set up in build_pyodide.sh. + source .venv/bin/activate + uv pip install pytest-pyodide + PYODIDE_ROOT_DIST=`pyodide config get pyodide_root`/dist + # `pytest-pyodide` requires pyodide in 'pyodide' directory in cwd, when running `pytest`. + cp -r $PYODIDE_ROOT_DIST test/pyodide + cp dist/ifcopenshell-*.whl test/pyodide + cd test + pytest --capture=no + - name: Pack Dependencies run: | cd ifcopenshell_build diff --git a/pyodide/test/test_wheel.py b/pyodide/test/test_wheel.py new file mode 100644 index 0000000000..1204c3d532 --- /dev/null +++ b/pyodide/test/test_wheel.py @@ -0,0 +1,27 @@ +from pathlib import Path + + +WHEEL_FILENAME = next( + p.name for p in (Path.cwd() / "pyodide").iterdir() if p.name.startswith("ifcopenshell-") and p.suffix == ".whl" +) + + +def test_ifcopenshell_import(selenium): + selenium.load_package("micropip") + # Important to test it with `micropip.install` + # without any dependencies loaded to ensure micropip will load them automatically. + selenium.run_async( + f""" + import micropip + await micropip.install(f"./{WHEEL_FILENAME}") + import ifcopenshell + ifc_file = ifcopenshell.file() + wall = ifc_file.create_entity("IfcWall") + wall1 = ifc_file.by_type("IfcWall")[0] + print(wall, wall1) + assert wall == wall1, "Wall entity doesn't match" + wall.Name = "Test" + assert wall.Name == "Test", f"Entity name wasn't changed: {{wall}}" + print(wall) + """ + )