Skip to content

boot.ps1: take a Python that starts and is 3.12+, not the Microsoft Store alias (BOOT-PS1-PYTHON-ALIAS) - #2902

Open
budanga wants to merge 2 commits into
ProjectLeonida:mainfrom
budanga:fix/boot-ps1-python-alias
Open

budanga wants to merge 2 commits into
ProjectLeonida:mainfrom
budanga:fix/boot-ps1-python-alias

Conversation

@budanga

@budanga budanga commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: BOOT-PS1-PYTHON-ALIAS (#1608 (comment))

What and why

scripts/windows-boot/boot.ps1 picks the Python for tools/boot_trace.py with Resolve-Python, which takes python as soon as Get-Command finds it. On Windows Get-Command also finds the Microsoft Store's app execution alias, %LOCALAPPDATA%\Microsoft\WindowsApps\python.exe, which only prints how to install Python and exits 9009. On a machine where Python is installed through py (the Python install manager without the python alias), the boot runs, but <name>.summary.txt holds only

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.

and py -3 is never tried. The same happens with a python older than 3.12, which cannot run boot_trace.py.

Change:

  • New Test-Python: starts the candidate with -I -c "import sys; sys.exit(sys.version_info < (3, 12))" and accepts it on exit 0. It waits at most 15 s; a candidate that has not exited by then is ended with its child processes (taskkill /T /F) and passed over, so a Python that hangs cannot hold the script after the game has stopped.
  • Resolve-Python tries python, then py -3, and takes the first that is found and passes Test-Python. -Python is still used as given.
  • The message when none works now says what was checked: no usable Python 3.12+ found for tools/boot_trace.py (checked 'python' and 'py -3'; specify -Python to use another interpreter).
  • .PARAMETER Python says so.

Nothing changes for a python that works (a python.org install, or Python from the Microsoft Store itself): it passes the check and is taken as before. The check costs one short Python start, after the game has stopped.

New test, tests/test_boot_ps1_python.py (standard library, Windows only): it takes Test-Python and Resolve-Python out of boot.ps1 and runs them in Windows PowerShell with stand-in python.cmd / py.cmd on a bare PATH:

  • the Store alias (exit 9009) is passed over for py -3;
  • a working python (the interpreter running the test) is taken;
  • a python older than 3.12 is passed over;
  • a python that hangs is given up on after 15 s for py -3, with no process left behind;
  • none that works gives none;
  • -Python is used as given.

With main's Resolve-Python in place, four of the six fail (the alias, the old Python, the hang and the none cases); with the change all pass.

Tested

On f107ae044, Windows 11 Home 26300.9974, Windows PowerShell 5.1, Python 3.14.10 from the install manager (py; python is only the Store alias, exit 9009):

  • python -I tests/test_boot_ps1_python.py: all 6 tests passed in 3 consecutive runs. Against main's Resolve-Python, 4 of the 6 tests fail.
  • End to end: boot.ps1 -DigestOnly -Name first on an earlier boot of mine. With main the summary is the Store message above; with this branch it is the boot_trace.py report (16 lines).
  • python -I tests/test_boot_trace.py, python -I tests/test_docs_cli_flags.py: pass.
  • python -I scripts/check_no_game_data.py on both files: passes.

GPUs tested: not relevant to this change; the end-to-end test was run on an AMD Radeon RX 9060 XT.

AI-assisted: yes (Claude Code)

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. (n/a: no translator rule)

🤖 Generated with Claude Code

…tore alias (BOOT-PS1-PYTHON-ALIAS)

Resolve-Python took `python` as soon as Get-Command found it. On Windows that also finds the Store's
app execution alias in WindowsApps, which only says how to install Python and exits 9009, so with
Python installed through `py` the boot's summary held that message and `py -3` was never tried.

Test-Python now starts each candidate (python, then py -3) and takes the first that exits 0 on a
3.12+ check, within 15 s; one that hangs is ended with its children and passed over. -Python is
used as given. tests/test_boot_ps1_python.py runs both functions against stand-in commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is right and I reproduced both halves: 6/6 on the branch, 4/6 failing with main's Resolve-Python, and on this box the probe is ~0.1 s after the game. It also survives the real-world shapes: an active venv on PATH resolves to python, an interpreter that prints its version to stderr is accepted with no noise (the probe reads no output at all), a hanging candidate is killed at 15.4 s with zero leftover processes, and a 0-byte broken alias returns cleanly instead of throwing.

One real gap: the 3.12 floor is untested. OLD in tests/test_boot_ps1_python.py:22 is just exit /b 1, so it tests "non-zero exit is rejected", not the version threshold. Changing (3, 12) to (3, 11) on boot.ps1:190 leaves all six tests green — I confirmed a 3.11-shaped interpreter is then accepted. A stand-in that fakes sys.version_info and execs the -c payload would make that mutation go red.

Two smaller things:

  • Assert the "no process left behind" claim in test_a_python_that_hangs_is_given_up_on; the test only bounds elapsed time, and I verified the taskkill /T behaviour manually rather than the suite doing it.
  • Residual, not a blocker: the probe trusts exit 0 alone, so a stub that starts and returns 0 without running the snippet is still taken (I reproduced it with an exit /b 0 stand-in). The real Store alias exits 9009, so the reported bug is fixed; if you want belt-and-braces, have the snippet print a marker and require it on stdout.

Merge is clean against current main — boot.ps1 grew around the section but its Python block is untouched, and the merged file passes the six tests.

@Kal0s-design

Copy link
Copy Markdown
Contributor

Verified on Windows 11, on a second machine with a different Python setup.

Head 48defb9c0 merged with main d2a564b66 (clean merge).

py -3.13 -I tests/test_boot_ps1_python.py -v: 6 tests, all OK, in 18.3 s. The hang case accounts for most of that, which fits the 15 s wait.

On a real PATH, no stand-ins. This machine has several interpreters. The first python on PATH is a 3.11.9 install. The WindowsApps python.exe / py.exe here are the Python install manager's aliases, and the classic py launcher is also present. I took Resolve-Python (plus Test-Python on the branch) out of each boot.ps1, the way the test does, and ran it with the real PATH. Then I started what it picked:

boot.ps1 from shell resolved that interpreter is
this branch Windows PowerShell 5.1 py -3 3.13.12
this branch PowerShell 7 py -3 3.13.12
main Windows PowerShell 5.1 python 3.11.9
main PowerShell 7 python 3.11.9

So the "older than 3.12" case in the description is not hypothetical: main hands boot_trace.py a 3.11 here, and the branch passes over it to py -3. It behaves the same under PowerShell 7. That matters because the test only drives powershell.exe, and the $p.Handle / Start-Process path works there too.

One small note: boot_trace.py --help itself still starts on 3.11 here. I did not check which part of a real report needs 3.12+. I went by the script's stated requirement.

Not checked: a full boot with the game (no game files here).

GPUs tested: n/a (script-only check).

AI-assisted: yes (Claude Code).

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent interpreter selection with installed Python versions at 48defb9c0 + 27613ab6b. I ran the extracted Resolve-Python and Test-Python functions under PowerShell 7.4.21 on Linux. A thin wrapper dropped the Windows-only -WindowStyle argument and delegated to the real Start-Process; interpreter paths in the fixture included spaces.

  • A Python 3.14.10 application on PATH is selected on both trees. A direct path to that interpreter also works on both.
  • With Python 3.11.17 first and a working py stand-in, main selects 3.11.17 and the PR selects py -3, which launches 3.14.10. With only 3.11.17 available the PR returns an empty selection.
  • A candidate that immediately exits 49 is also skipped in favor of py -3. The stand-in verifies the -3 argument before forwarding to the installed interpreter.

The fixture covers selection and process arguments. Windows Store alias and process-tree timeout behavior are covered by the native Windows tests above. MEASURED. AI-assisted (Codex).

…e leaves no process (BOOT-PS1-PYTHON-ALIAS)

The older-Python stand-in only exited 1, so changing (3, 12) in Test-Python left every test green. A stand-in now
runs Test-Python's own check with sys.version_info set: 3.11.9 is passed over for py -3 and 3.12.0 is taken. The
hanging stand-in sleeps in a Python child with a unique tag on its command line, and the test asserts that no
process holding the tag is left once Resolve-Python returns.

Test-Python's comment now gives the requirement it follows: the repository needs 3.12+ (README.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@budanga

budanga commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and the runs on other setups.

KelboLive's three points. The new commit changes the test only; the probe in boot.ps1 is the same:

  1. The 3.12 floor: the OLD stand-in is gone. A new one runs Test-Python's own check with sys.version_info set to a given version. 3.11.9 must be passed over for py -3, and a new test takes 3.12.0 as python.
  2. No process left behind: the hanging stand-in now sleeps in a Python child whose command line holds a unique tag. After Resolve-Python returns, the test asserts that no process with that tag is left.
  3. A stub that exits 0 without running the check: I'd leave it. The real Store alias exits 9009, which is the bug reported. A marker on stdout would make Start-Process redirect to a temporary file, for a case nobody has seen.

Mutations, python -I tests/test_boot_ps1_python.py (Windows 11 26300, Python 3.14.10):

change in boot.ps1 result
none 7 OK, 3 runs out of 3
(3, 12) -> (3, 11) FAIL test_a_python_older_than_3_12_is_passed_over
(3, 12) -> (3, 13) FAIL test_python_3_12_is_taken
taskkill /T /F -> $p.Kill() (the cmd only, not its child) FAIL test_a_python_that_hangs_is_given_up_on: the hanging stand-in's child outlived Test-Python

Kal0s-design's note on boot_trace.py --help under 3.11. Fair: I had not shown that boot_trace.py itself fails on 3.11. The comment in Test-Python now gives the requirement it actually follows: the repository needs 3.12+ (README.md).

check_no_game_data.py is clean on both files.

AI-assisted (Claude Code).

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Python floor and timeout check on the updated head 29831328 on main 60f7dcd9, using the actual resolver functions with PowerShell 7.4.21 on Linux. A stand-in that executes the version expression with sys.version_info=(3,11,9) selected py -3, and one reporting 3.12.0 selected python. Lowering only the predicate to 3.11 changed the first result back to python. The failing alias stand-in selected py -3, alias-only returned an empty selection, and the explicit path with spaces was preserved.

A hanging local parent and child triggered the resolver’s cleanup request with the parent PID. The resolver selected py -3 after 15.034 s, and both fixture processes were inactive on return. The Linux harness kept the real Start-Process, omitted Windows-only -WindowStyle, and used a scoped .NET process-tree shim for the cleanup request. The native Windows cleanup tool is covered by the separate native runs.

MEASURED with synthetic candidates. AI-assisted (Codex).

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Merging. Head 298313282 merges cleanly with main c4ca57615 and does not force a rebase of #2566. Ran main (c4ca576) plus the PR myself: test_boot_ps1_python 7 green and 7 red with boot.ps1 reverted; line endings and stdout encoding green; ci_registration failed once under load, then 18 green on rerun with the PR (and green on main alone). Third-party check by merzleckeier on this head; read-only code review found nothing blocking. Merged by MoonEyes.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants