Skip to content

Installer: verify the interpreter version the py launcher resolves to - #131

Merged
MrDix merged 1 commit into
mainfrom
fix/installer-verify-py-launcher-version
Jul 15, 2026
Merged

Installer: verify the interpreter version the py launcher resolves to#131
MrDix merged 1 commit into
mainfrom
fix/installer-verify-py-launcher-version

Conversation

@MrDix

@MrDix MrDix commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Problem

On a machine whose py launcher resolves the -3.13/-3.12 tag to a wrong interpreter (e.g. a stale registry registration left behind by a Python upgrade or uninstall), the Windows installers hand that interpreter straight to uv sync --python, which then aborts:

Using CPython 3.10.11 interpreter at: C:\Users\...\Python310\python.exe
error: The requested interpreter resolved to Python 3.10.11, which is
incompatible with the project's Python requirement: '>=3.12, <3.14'
Error during uv sync

This happened after uv lock had already succeeded, so the run failed at the very last step.

Root cause

The py-launcher discovery block only checked the launcher's exit code, never the version of the interpreter it actually returned. The PATH fallback right below it already verifies sys.version_info before accepting a candidate — the launcher block was the one discovery path without that check, and it is also the only path that can produce a full interpreter path, which matches the failure output above.

Fix

Verify the major.minor version of the interpreter the launcher resolves (same check the PATH fallback uses). On mismatch, discovery falls through to the PATH fallback and finally to the portable uv-managed Python 3.12, so the installer now self-heals on such machines instead of aborting.

Applied to both install/CPU/windows_cpu.bat and install/CUDA/windows_cuda_gpu.bat (identical block).

Testing

  • Extracted the discovery block into a standalone test script: on a healthy machine it still picks the launcher-resolved Python 3.12 (verified path + version).
  • Simulated a mismatching launcher (requested tag differs from the returned version): the candidate is rejected and discovery correctly continues to the PATH fallback.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Python version detection during Windows CPU and CUDA GPU installations.
    • Installers now verify that the Python interpreter selected by the launcher matches the requested major and minor version.
    • If a mismatch is detected, the installer continues searching for a compatible interpreter instead of selecting an incorrect one.
    • This helps prevent installation failures and compatibility issues caused by using the wrong Python version.

The Windows installers trusted the py launcher blindly: when "py -3.13"
or "py -3.12" exited successfully, the resolved sys.executable was used
for "uv sync --python" without checking its actual version. A stale or
wrong launcher registration (e.g. a registry entry left behind by a
Python upgrade or uninstall) can resolve such a tag to an old install
like Python 3.10, which then fails the sync with:

  error: The requested interpreter resolved to Python 3.10.11, which is
  incompatible with the project's Python requirement: '>=3.12, <3.14'

Verify the major.minor version of the interpreter the launcher returns,
mirroring the check the PATH fallback already does. On mismatch the
discovery now falls through to the PATH fallback and finally to the
portable uv-managed Python 3.12, so the install self-heals instead of
aborting.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3b4b805-cd84-49b3-8940-d0c101ae2217

📥 Commits

Reviewing files that changed from the base of the PR and between 02ee3db and 9fabd36.

📒 Files selected for processing (2)
  • install/CPU/windows_cpu.bat
  • install/CUDA/windows_cuda_gpu.bat

📝 Walkthrough

Walkthrough

The Windows CPU and CUDA installer scripts now compute and compare the resolved interpreter’s major.minor version with the requested py launcher tag before setting PYTHON_EXE and completing Python discovery.

Changes

Windows Python validation

Layer / File(s) Summary
Validate Python launcher resolution
install/CPU/windows_cpu.bat, install/CUDA/windows_cuda_gpu.bat
The installer loops compute each candidate interpreter’s major.minor version and only accept matching versions before capturing sys.executable and jumping to :found_python.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • MrDix/UltraSinger#111: Modifies the Windows CPU/CUDA installer scripts’ Python provisioning and interpreter-selection logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: validating the Python version resolved by the Windows installer’s py launcher.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/installer-verify-py-launcher-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MrDix
MrDix merged commit 0bd42a3 into main Jul 15, 2026
2 checks passed
@MrDix
MrDix deleted the fix/installer-verify-py-launcher-version branch July 15, 2026 01:56
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.

1 participant