mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 03:18:52 -06:00
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.
This commit is contained in:
1 parent
fb17242a78
commit
ccd440f67a
7 files changed
+33
-50
No files matched your search
@@ -0,0 +1,23 @@
|
||||
"""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
|
||||
Reference in new issue
Block a user