mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 12:12:15 +00:00
pyodide/test_wheel: make it support modular wheels
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
pyodide
|
||||
pyodide-modular
|
||||
+22
-11
@@ -1,18 +1,30 @@
|
||||
import zipfile
|
||||
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"
|
||||
)
|
||||
from ..order_pyodide_wheel_shared_objects import shared_object_sort_key
|
||||
|
||||
|
||||
def test_ifcopenshell_import(selenium):
|
||||
def _first_so_name(wheel_path: Path) -> str:
|
||||
with zipfile.ZipFile(wheel_path) as zf:
|
||||
for name in zf.namelist():
|
||||
if name.endswith(".so"):
|
||||
return Path(name).name
|
||||
return wheel_path.name
|
||||
|
||||
|
||||
def test_ifcopenshell_import(selenium, request):
|
||||
dist_dir = Path(request.config.getoption("--dist-dir"))
|
||||
wheel_paths = list(dist_dir.glob("ifcopenshell*.whl"))
|
||||
wheel_paths.sort(key=lambda path: shared_object_sort_key(_first_so_name(path), 0))
|
||||
WHEEL_NAMES = tuple(path.name for path in wheel_paths)
|
||||
|
||||
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"""
|
||||
selenium.run_async(f"""
|
||||
import micropip
|
||||
await micropip.install(f"./{WHEEL_FILENAME}")
|
||||
wheel_filenames = {WHEEL_NAMES!r}
|
||||
for wheel_filename in wheel_filenames:
|
||||
print(f"Loading {{wheel_filename}}...")
|
||||
await micropip.install(f"./{{wheel_filename}}")
|
||||
import ifcopenshell
|
||||
from pathlib import Path
|
||||
ifcopenshell.set_plugin_search_paths([str(Path(ifcopenshell.__file__).parent)])
|
||||
@@ -24,5 +36,4 @@ def test_ifcopenshell_import(selenium):
|
||||
wall.Name = "Test"
|
||||
assert wall.Name == "Test", f"Entity name wasn't changed: {{wall}}"
|
||||
print(wall)
|
||||
"""
|
||||
)
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user