Skip to content

Windows installer: prefer uv-managed Python over global winget installs - #7825

Merged
danielhanchen merged 12 commits into
unslothai:mainfrom
AryanGupta1112:fix/windows-uv-managed-python-7802
Oct 5, 2026
Merged

danielhanchen merged 12 commits into
unslothai:mainfrom
AryanGupta1112:fix/windows-uv-managed-python-7802

Conversation

@AryanGupta1112

@AryanGupta1112 AryanGupta1112 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7802.

On a Windows host with no Python 3.11 to 3.13, install.ps1 installed CPython system-wide (winget, then python.org) and only then used uv to build the Studio venv. uv can provide the interpreter itself, so the system install is unnecessary on most machines.

Change

  • When no compatible interpreter is found on a non-ARM64 host, the Python step now defers to uv. Once uv is set up, Resolve-UvManagedPython runs uv python install --no-bin --no-registry <minor> and uv python find --system --managed-python <minor>, and the venv is created from that interpreter path.
    • --no-bin / --no-registry: only uv's own Python store changes; nothing is added to PATH, ~/.local/bin, or the py launcher registry.
    • --system on find: without it uv answers with an active venv's python.
    • Skipped patches (3.13.8) are excluded in the request itself (>=3.13,<3.14,!=3.13.8, as install.sh does), so a cached healthy patch is reused offline; the full version is re-checked under -S before use.
  • If uv cannot provide Python (offline, python-downloads = never, policy), the previous winget / python.org install runs unchanged as a fallback, so no machine loses its install path.
  • An existing system Python 3.11 to 3.13 is still preferred, and Windows on ARM keeps the system install (its x64 vs ARM64 selection depends on it).

Tests

tests/python/test_windows_uv_managed_python.py runs Resolve-UvManagedPython under pwsh / Windows PowerShell against a fake uv (success, failed install, nothing found, skipped patch) and pins the ordering: defer, uv setup, uv resolution, system fallback, venv creation. The existing Windows Python selection suites (test_windows_on_arm_python_arch.py, test_windows_python_313_8_screen.py, test_windows_python_venv_hardening.py, test_windows_arm64_python_choice.py) still pass. The function was also run against a real uv 0.10.7 with an active venv: it returned the managed interpreter, uv venv --python <path> built from it, and no executable was added to ~/.local/bin.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@vladimir-light

Copy link
Copy Markdown

FYI, my python (and also UV) istalled via scoop and live under %USER%\scoop\apps\python\3.14\python.exe . Win-installer didn't see it at all and always tries to install 3.13.x
It would be much nicer to give users options, such as "Let us do it for you" (which would behave in the same way) or letting users provide a path to python and/or uv and checking whether the specified versions are suitable for Unsloth.

… as fallback

Re-implements unslothai#7802 on current main: when no Python 3.11-3.13 is found on a
non-ARM64 host, install.ps1 now asks uv for a managed interpreter
(uv python install --no-bin --no-registry) once uv is set up, instead of
installing Python system-wide through winget / python.org. If uv cannot
provide one (offline, python-downloads disabled, skipped patch), the
previous winget / python.org install runs as before. Windows on ARM keeps
the system install.
@shimmyshimmer

Copy link
Copy Markdown
Member

Review record for #7825, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#447.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 8c4f753f7 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 8c4f753f7e

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 8c4f753f7 (no equivalent commit found on this PR).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Installs Python on Windows

4 participants