Spaces:
Running on Zero
Running on Zero
| from __future__ import annotations | |
| import runpy | |
| from importlib.util import module_from_spec, spec_from_file_location | |
| from pathlib import Path | |
| ROOT_APP_PATH = Path(__file__).resolve().parent.parent / "app.py" | |
| def _load_root_app_module(): | |
| if not ROOT_APP_PATH.exists(): | |
| raise ModuleNotFoundError( | |
| "The source checkout app.py entrypoint is not available " | |
| "from this installation." | |
| ) | |
| spec = spec_from_file_location("_trellis2_root_app", ROOT_APP_PATH) | |
| if spec is None or spec.loader is None: | |
| raise ImportError(f"Unable to create an import spec for {ROOT_APP_PATH}") | |
| module = module_from_spec(spec) | |
| spec.loader.exec_module(module) | |
| return module | |
| _ROOT_APP = _load_root_app_module() | |
| _PUBLIC_NAMES = getattr(_ROOT_APP, "__all__", None) | |
| if _PUBLIC_NAMES is None: | |
| _PUBLIC_NAMES = [name for name in dir(_ROOT_APP) if not name.startswith("__")] | |
| globals().update({name: getattr(_ROOT_APP, name) for name in _PUBLIC_NAMES}) | |
| __all__ = list(_PUBLIC_NAMES) # pyright: ignore[reportUnsupportedDunderAll] | |
| if __name__ == "__main__": | |
| runpy.run_path(str(ROOT_APP_PATH), run_name="__main__") | |