mirror of
https://github.com/lutris/lutris.git
synced 2026-06-17 10:19:58 -04:00
8789d2bbbstopped publishing PYTHONPATH when launching lutris-wrapper, on the assumption the wrapper's own sys.path bootstrap covered every case it needed to. It didn't: anyone running `./bin/lutris` from a git checkout without installing Lutris would now hit ModuleNotFoundError: No module named 'lutris' at the wrapper's `from lutris.util.log import logger` line, before the wrapper had a chance to do anything. Two compounding causes: 1. The wrapper's bootstrap code lived inside `if __name__ == "__main__"`, meaning it ran AFTER the top-level `from lutris...` imports. The imports had to succeed first, and they were silently relying on the parent process having injected PYTHONPATH=":".join(sys.path) into the env before exec. 2. Even when it did run, the bootstrap's source-mode detection was checking `LAUNCH_PATH/../lutris` — i.e. `share/lutris/lutris/` — which has never existed. The check fell through to a second never-existent path. So the bootstrap was, in practice, dead code regardless of when it ran. This commit fixes both: * Move the source-tree detection above the lutris imports and look three directories up (`share/lutris/bin/` → repo root), where the `lutris/` package actually lives. Confirm via the package's `__init__.py` rather than just a directory match. * Restore `env["PYTHONPATH"] = ":".join(sys.path)` in monitored_command as defense-in-depth. The wrapper now runs on the same Python as Lutris (sys.executable, via the existing8789d2bbbchange), so the inherited PYTHONPATH is ABI-compatible; and lutris-wrapper deletes PYTHONPATH from os.environ before spawning the game, so the leak doesn't reach Wine, umu-launcher, or any other runner subprocess. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>