The torchvision detector drop-in, headless pyrender/OpenGL shims, and the detector+smoke tests existed only on ultra's disk inside gitignored .engine/. Captured byte-identical copies into engine_patches/ (mirrors the HSMR subtree) and moved setup_hsmr.sh to the repo root (tracked, path-relative) with a --patch step that overlays them onto the clone. Acceptance PASSED: fresh shallow clone of HSMR in a temp dir + './setup_hsmr.sh --patch' + validated venv -> test_detector.py green (7/7 demo imgs, 15 patches), no hand edits. A re-clone can no longer silently drop the ARM fixes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Headless-macOS import shims for the HSMR engine (our fleet is all Apple Silicon).
|
|
|
|
pyrender -> PyOpenGL -> EGL cannot load without a GL context, yet several vendored modules
|
|
`import pyrender` at load time — some even in type annotations (`List[pyrender.Node]`) — so
|
|
the import chain explodes before any of our code runs. We never render in-process; Blender
|
|
is the fleet renderer (Lane C). So we drop permissive fakes for the pyrender + OpenGL stack
|
|
into sys.modules, letting the chain import while keeping everything else (ColorPalette,
|
|
Wis3D, the models) real.
|
|
|
|
Import this BEFORE the first `lib.*` import: `import _headless # noqa: F401`
|
|
|
|
# ponytail: fakes, not a real headless GL backend (osmesa/egl). We don't render here, so a
|
|
# working GL context would be dead weight. Wire a real one only if in-process render is ever
|
|
# needed off-fleet.
|
|
"""
|
|
import sys
|
|
import types
|
|
|
|
|
|
class _Any:
|
|
def __call__(self, *a, **k): return self
|
|
def __getattr__(self, n): return self
|
|
|
|
|
|
class _AnyModule(types.ModuleType):
|
|
def __getattr__(self, n):
|
|
if n.startswith('__') and n.endswith('__'):
|
|
raise AttributeError(n)
|
|
return _Any()
|
|
|
|
|
|
# setdefault: never clobber a real module that a caller already imported on purpose.
|
|
for _n in ('pyrender', 'OpenGL', 'OpenGL.GL', 'OpenGL.error', 'OpenGL.platform'):
|
|
sys.modules.setdefault(_n, _AnyModule(_n))
|