Files
lutris/share
Daniel Johnson 44acabb77e Make lutris-wrapper self-bootstrap in source-tree mode. Resolves #6730
8789d2bbb stopped 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 existing 8789d2bbb change), 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>
2026-06-11 17:14:52 -04:00
..
2021-03-22 15:21:50 -07:00
2026-03-16 00:43:17 -07:00