Files
libretro/scripts/installer_build/module.py
T
Abdessamad Derraz ccd440f67a refactor: load install.py as a module in one place
The event schema, the installer doc, the launcher index, the site and the README each executed install.py with their own importlib block. installer_build.module.installer_module is cached and read by all five.
2026-11-21 06:02:35 +01:00

24 lines
712 B
Python

"""install.py read as a module, once per run."""
from __future__ import annotations
import functools
import importlib.util
import types
from core.paths import REPO_ROOT
@functools.cache
def installer_module() -> types.ModuleType:
"""The generated install.py, the artifact served, for its constants and
words: the schema, the doc tables, the launcher index and the site read
the same module."""
path = REPO_ROOT / "install.py"
spec = importlib.util.spec_from_file_location("install", path)
if spec is None or spec.loader is None:
raise ImportError(f"cannot load {path}")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module