33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
"""Read the real installer for focused tests; no installation logic is copied."""
|
|
|
|
from pathlib import Path
|
|
from types import ModuleType
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
ENTRY = ROOT / "install"
|
|
|
|
|
|
def entry_parts():
|
|
entry = ENTRY.read_text()
|
|
opening = "<<'DEVER_INSTALL_PYTHON'\n"
|
|
closing = "\nDEVER_INSTALL_PYTHON\n"
|
|
if entry.count(opening) != 1 or entry.count(closing) != 1:
|
|
raise ValueError("root install must contain exactly one Python heredoc")
|
|
before, remainder = entry.split(opening)
|
|
source, after = remainder.split(closing)
|
|
return before + opening, source, closing + after
|
|
|
|
|
|
def load_installer():
|
|
_, source, _ = entry_parts()
|
|
module = ModuleType("dever_installer")
|
|
exec(compile(source, str(ENTRY) + "::python", "exec"), module.__dict__)
|
|
return module
|
|
|
|
|
|
def entry_with_python(probe):
|
|
"""Keep the actual shell wrapper while a harmless probe observes its contract."""
|
|
before, _, after = entry_parts()
|
|
return before + probe.rstrip("\n") + after
|