83 lines
2.8 KiB
Python
83 lines
2.8 KiB
Python
"""Post-build smoke tests for packaged wheels and standalone GUI builds."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import venv
|
|
from pathlib import Path
|
|
|
|
from paths import GUI_DIST_DIR
|
|
|
|
|
|
def _venv_python(venv_dir: Path) -> Path:
|
|
if sys.platform == "win32":
|
|
return venv_dir / "Scripts" / "python.exe"
|
|
return venv_dir / "bin" / "python"
|
|
|
|
|
|
def verify_built_wheel(wheel_path: Path) -> None:
|
|
"""Install the wheel in a temporary venv and smoke-test finger imports."""
|
|
wheel_path = wheel_path.resolve()
|
|
with tempfile.TemporaryDirectory(prefix="orisys-wheel-verify-") as tmp:
|
|
venv_dir = Path(tmp) / "venv"
|
|
venv.create(venv_dir, with_pip=True)
|
|
python = _venv_python(venv_dir)
|
|
|
|
subprocess.check_call(
|
|
[python, "-m", "pip", "install", "-q", str(wheel_path)],
|
|
)
|
|
subprocess.check_call(
|
|
[
|
|
python,
|
|
"-c",
|
|
(
|
|
"from orisys.finger import UVMeshViewer, build_uv_surface_mesh, FingerRuntime; "
|
|
"from orisys.finger.mesh import UVSurfaceMesh; "
|
|
"from orisys.finger.viewer import init_uv_mesh_viewer; "
|
|
"print('finger mesh/viewer imports OK')"
|
|
),
|
|
],
|
|
)
|
|
|
|
|
|
def verify_gui_dist(dist_dir: Path | None = None) -> None:
|
|
"""Smoke-test a standalone GUI folder produced by build_gui_win.py."""
|
|
dist_dir = (dist_dir or GUI_DIST_DIR).resolve()
|
|
exe = dist_dir / "OrisysDashboard.exe"
|
|
if not exe.is_file():
|
|
raise FileNotFoundError(f"GUI executable not found: {exe}")
|
|
|
|
required = [
|
|
dist_dir / "config" / "dd02-ov.json",
|
|
dist_dir / "assets" / "finger" / "visualization" / "world_to_cam.npy",
|
|
dist_dir / "assets" / "finger" / "30fps" / "mesh.npz",
|
|
]
|
|
missing = [str(path.relative_to(dist_dir)) for path in required if not path.is_file()]
|
|
if missing:
|
|
raise FileNotFoundError(f"Missing bundled files in {dist_dir}: {', '.join(missing)}")
|
|
|
|
subprocess.check_call([str(exe), "--help"], cwd=dist_dir)
|
|
print(f"GUI dist smoke test OK: {exe}")
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="Verify packaged Orisys artifacts.")
|
|
parser.add_argument("--gui-dist", action="store_true", help="Verify dist/OrisysDashboard/")
|
|
parser.add_argument("--dist-dir", type=Path, default=None, help="Override GUI dist folder")
|
|
parser.add_argument("wheel", nargs="?", type=Path, help="Wheel path for import smoke test")
|
|
args = parser.parse_args()
|
|
|
|
if args.gui_dist:
|
|
verify_gui_dist(args.dist_dir)
|
|
return
|
|
if args.wheel is None:
|
|
parser.error("Provide a wheel path or pass --gui-dist")
|
|
verify_built_wheel(args.wheel)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|