Build.bat/Mods.bat: quote per-user Python paths, sync lookup, and add no-pause guard #2342

Merged
kirigayakazima merged 1 commit from upstream-pr/2342 into main 2026-11-29 00:59:07 +00:00
kirigayakazima commented 2026-11-26 14:12:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T14:12:19Z.


Claimed in the coordination issue as: WIN-LAUNCHERS-BUILD-MODS-BAT-QUOTING-USER-PYTHON-AND-NO-PAUSE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194337029)

What and why

  • Quote per-user Python resolution safely in Build.bat and Mods.bat by splitting PY into quoted PY_EXE and PY_ARG (set "PY_EXE=%~1", invoking "%PY_EXE%" %PY_ARG% -I ...) and quoting "%~1" in :try_python so per-user install paths containing spaces or & work without unquoted syntax errors.
  • Add :find_user_python and :try_python to Mods.bat (matching Build.bat) so per-user Python installs under %LOCALAPPDATA%\Programs\Python\Python3* work in the mod manager launcher as well.
  • Guard interactive pause calls in both Build.bat and Mods.bat with if not defined LEONIDA_NO_PAUSE pause, and add PYTMP fallbacks (%TEMP% -> %LOCALAPPDATA%\Temp -> %~dp0) in Build.bat's :py_download.
  • Add standard-library tests in tests/test_win_launchers.py.

Tested

  • python -I tests/test_win_launchers.py -v: 2 passed, 0 failed (detached upstream/main baseline with only the new test file fails with 2 failures).
  • python -I tests/test_ci_registration.py: 16 passed.
  • python -I tests/test_text_write_line_endings.py: 3 passed.
  • python -I scripts/check_no_game_data.py, python -I -m compileall -q tests/test_win_launchers.py, and git diff --cached --check: passed.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5511580515 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2342). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-26T14:12:19Z. --- Claimed in the coordination issue as: WIN-LAUNCHERS-BUILD-MODS-BAT-QUOTING-USER-PYTHON-AND-NO-PAUSE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194337029) ### What and why - Quote per-user Python resolution safely in `Build.bat` and `Mods.bat` by splitting `PY` into quoted `PY_EXE` and `PY_ARG` (`set "PY_EXE=%~1"`, invoking `"%PY_EXE%" %PY_ARG% -I ...`) and quoting `"%~1"` in `:try_python` so per-user install paths containing spaces or `&` work without unquoted syntax errors. - Add `:find_user_python` and `:try_python` to `Mods.bat` (matching `Build.bat`) so per-user Python installs under `%LOCALAPPDATA%\Programs\Python\Python3*` work in the mod manager launcher as well. - Guard interactive `pause` calls in both `Build.bat` and `Mods.bat` with `if not defined LEONIDA_NO_PAUSE pause`, and add `PYTMP` fallbacks (`%TEMP%` -> `%LOCALAPPDATA%\Temp` -> `%~dp0`) in `Build.bat`'s `:py_download`. - Add standard-library tests in `tests/test_win_launchers.py`. ### Tested - `python -I tests/test_win_launchers.py -v`: 2 passed, 0 failed (detached `upstream/main` baseline with only the new test file fails with 2 failures). - `python -I tests/test_ci_registration.py`: 16 passed. - `python -I tests/test_text_write_line_endings.py`: 3 passed. - `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q tests/test_win_launchers.py`, and `git diff --cached --check`: passed. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
lixonik commented 2026-11-26 15:40:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:40:31Z.

Review: COMMENTED


Windows 11: both launcher tests passed, including native cmd.exe and PowerShell tests with a disposable per-user Python path containing spaces and an ampersand, LEONIDA_NO_PAUSE, and exact exit-code propagation. No findings.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6076919383 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2342#pullrequestreview-6076919383). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T15:40:31Z. **Review:** COMMENTED --- Windows 11: both launcher tests passed, including native cmd.exe and PowerShell tests with a disposable per-user Python path containing spaces and an ampersand, `LEONIDA_NO_PAUSE`, and exact exit-code propagation. No findings. AI-assisted.
zmasi commented 2026-11-28 12:57:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:57:28Z.


#2342 | head 6f015d8345 (merged cleanly with main d48a957bb) | python -I tests/test_win_launchers.py | red on main: FAILED (failures=2) (Build.bat unquoted %1 broke per-user Python paths containing &, Mods.bat lacked :find_user_python, and neither launcher supported LEONIDA_NO_PAUSE) | green on PR+main: 2 tests OK | Windows 11 (10.0.26200.9974, cmd.exe + powershell.exe 5.1.26100.9818), Python 3.12.10 | AI-assisted: yes

Audited Build.bat, Mods.bat, and tests/test_win_launchers.py on Windows 11 (cmd.exe + powershell.exe Add-Type C# stub python.exe), verifying split PY_EXE / PY_ARG quoting ("%PY_EXE%" %PY_ARG% -I ...), :find_user_python per-user Python discovery under paths containing & (user & test\Programs\Python\Python313\python.exe), PYTMP fallback when %TEMP% is unset, LEONIDA_NO_PAUSE non-interactive exit without blocking on pause, and exact exit-code propagation (0, 5, 1). Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239585822 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2342#issuecomment-7239585822). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T12:57:28Z. --- #2342 | head 6f015d8345cfe90d32820ba686cdf234ba2113d7 (merged cleanly with main d48a957bb) | `python -I tests/test_win_launchers.py` | red on main: `FAILED (failures=2)` (`Build.bat` unquoted `%1` broke per-user Python paths containing `&`, `Mods.bat` lacked `:find_user_python`, and neither launcher supported `LEONIDA_NO_PAUSE`) | green on PR+main: `2 tests OK` | Windows 11 (`10.0.26200.9974`, `cmd.exe` + `powershell.exe` `5.1.26100.9818`), Python 3.12.10 | AI-assisted: yes Audited `Build.bat`, `Mods.bat`, and `tests/test_win_launchers.py` on Windows 11 (`cmd.exe` + `powershell.exe` `Add-Type` C# stub `python.exe`), verifying split `PY_EXE` / `PY_ARG` quoting (`"%PY_EXE%" %PY_ARG% -I ...`), `:find_user_python` per-user Python discovery under paths containing `&` (`user & test\Programs\Python\Python313\python.exe`), `PYTMP` fallback when `%TEMP%` is unset, `LEONIDA_NO_PAUSE` non-interactive exit without blocking on `pause`, and exact exit-code propagation (`0`, `5`, `1`). Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
DadaCap commented 2026-11-29 00:59:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T00:59:21Z.


Merged, thank you! Its own tests failed on main without the change and passed with it, and a batch test with eight other tool PRs (main's Python suite plus a game run on an RTX 5080) showed no regression.

AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248485089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2342#issuecomment-7248485089). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-29T00:59:21Z. --- Merged, thank you! Its own tests failed on main without the change and passed with it, and a batch test with eight other tool PRs (main's Python suite plus a game run on an RTX 5080) showed no regression. AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2342
No description provided.