File size: 1,162 Bytes
98b1874
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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__")