Skip to content

Commit 1f8c12a

Browse files
committed
build_pyodide - test wasm wheel working
1 parent 89a6eac commit 1f8c12a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/build_pyodide.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ jobs:
4949
ifcopenshell_build/*/*/logs/*.log
5050
retention-days: 30
5151

52+
- name: Run wheel tests
53+
run: |
54+
cp -r IfcOpenShell/pyodide/test test
55+
# venv set up in build_pyodide.sh.
56+
source .venv/bin/activate
57+
uv pip install pytest-pyodide
58+
PYODIDE_ROOT_DIST=`pyodide config get pyodide_root`/dist
59+
# `pytest-pyodide` requires pyodide in 'pyodide' directory in cwd, when running `pytest`.
60+
cp -r $PYODIDE_ROOT_DIST test/pyodide
61+
cp dist/ifcopenshell-*.whl test/pyodide
62+
cd test
63+
pytest --capture=no
64+
5265
- name: Pack Dependencies
5366
run: |
5467
cd ifcopenshell_build

pyodide/test/test_wheel.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pathlib import Path
2+
3+
4+
WHEEL_FILENAME = next(
5+
p.name for p in (Path.cwd() / "pyodide").iterdir() if p.name.startswith("ifcopenshell-") and p.suffix == ".whl"
6+
)
7+
8+
9+
def test_ifcopenshell_import(selenium):
10+
selenium.load_package("micropip")
11+
# Important to test it with `micropip.install`
12+
# without any dependencies loaded to ensure micropip will load them automatically.
13+
selenium.run_async(
14+
f"""
15+
import micropip
16+
await micropip.install(f"./{WHEEL_FILENAME}")
17+
import ifcopenshell
18+
ifc_file = ifcopenshell.file()
19+
wall = ifc_file.create_entity("IfcWall")
20+
wall1 = ifc_file.by_type("IfcWall")[0]
21+
print(wall, wall1)
22+
assert wall == wall1, "Wall entity doesn't match"
23+
wall.Name = "Test"
24+
assert wall.Name == "Test", f"Entity name wasn't changed: {{wall}}"
25+
print(wall)
26+
"""
27+
)

0 commit comments

Comments
 (0)