# SPDX-License-Identifier: MIT """Find the GPL tools kept outside this repository (docs/provenance.md). Mesen2's ctypes driver (``mesen_run.py``) declares Mesen2's exported C API, so it is a GPL tool: it left this repository with its history rewrite of 2026-11-22 and is kept with the family's other GPL tools. Importing this module puts the directory named by ``SNES_GPL_TOOLS`` on ``sys.path`` (so ``import mesen_run`` works), tells the tool where this checkout is (``SNES_PYTHON_ROOT``, inherited by subprocesses), and gives the scripts that run it as a separate program its path (``tool("mesen_run.py")``). The same folder holds the S-DSP referee's driver, ``spc_dump.cpp`` (linked with snes_spc, LGPL), which ``dsp_build_referees.py`` compiles from there. """ import os import sys from pathlib import Path os.environ.setdefault("SNES_PYTHON_ROOT", str(Path(__file__).resolve().parents[1])) TOOLS = os.environ.get("SNES_GPL_TOOLS") if TOOLS and TOOLS not in sys.path: sys.path.insert(0, TOOLS) def tool(name: str) -> Path: """The path of one parked GPL tool, or exit saying how to find it.""" path = Path(TOOLS or ".") / name if not TOOLS or not path.exists(): raise SystemExit(f"{name} is a GPL tool kept outside this repository: set SNES_GPL_TOOLS") return path