Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Installer (Windows): fall back to the python-build-standalone mirror for uv-managed Python (#14686)

Daniel Han5c1b054a5f8c
diff --git a/install.ps1 b/install.ps1
index c45813c97de..f8cae4cfae9 100644
--- a/install.ps1
+++ b/install.ps1
@@ -4565,12 +4565,28 @@ function Install-UnslothStudio {
}
function Test-MirrorConfigured {
- param([ValidateSet('uv', 'pip')][string]$Tool)
- if ($Tool -eq 'uv') {
- if ("$env:UV_DEFAULT_INDEX$env:UV_INDEX_URL$env:UV_INDEX$env:UV_EXTRA_INDEX_URL") { return $true }
- $pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
- $files = @($env:UV_CONFIG_FILE, "$env:APPDATA\uv\uv.toml", "$env:ProgramData\uv\uv.toml")
+ param([ValidateSet('uv', 'python', 'pip')][string]$Tool)
+ if ($Tool -ne 'pip') {
+ if ($Tool -eq 'python') {
+ # UV_PYTHON_INSTALL_MIRROR would override UV_ASTRAL_MIRROR_URL; uv rejects a mirror beside a custom manifest.
+ if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL$env:UV_PYTHON_DOWNLOADS_JSON_URL") { return $true }
+ $pattern = '^\s*(python-install-mirror|python-downloads-json-url)\s*='
+ } else {
+ if ("$env:UV_DEFAULT_INDEX$env:UV_INDEX_URL$env:UV_INDEX$env:UV_EXTRA_INDEX_URL") { return $true }
+ $pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
+ }
+ # uv's discovery: UV_CONFIG_FILE alone (even with UV_NO_CONFIG); relative paths from --directory.
+ # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper.
+ $uvTrue = @('1', 't', 'true', 'y', 'yes', 'on')
+ $files = @("$env:APPDATA\uv\uv.toml")
+ if ($uvTrue -notcontains "$env:UV_NO_SYSTEM_CONFIG".Trim().ToLowerInvariant()) { $files += "$env:ProgramData\uv\uv.toml" }
$dir = (Get-Location -PSProvider FileSystem).ProviderPath
+ $workDir = if ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY }
+ if ($workDir) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $workDir)) }
+ $configFile = if ($env:UV_CONFIG_FILE) { [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_CONFIG_FILE)) }
+ if ($env:UV_PROJECT) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_PROJECT)) }
+ if ($configFile) { $files = @($configFile); $dir = $null }
+ elseif ($uvTrue -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null }
while ($dir) {
$pyproject = Join-Path $dir 'pyproject.toml'
if (Test-Path -LiteralPath (Join-Path $dir 'uv.toml') -PathType Leaf) { $files += Join-Path $dir 'uv.toml'; break }
@@ -4672,6 +4688,8 @@ function Install-UnslothStudio {
$cernet = 'https://tuna.mirrors.cernet.edu.cn'
$npmMirror = 'https://registry.npmmirror.com'
$pypiMirror = "$cernet/pypi/web/simple"
+ # GitHub-release mirrors keep only the newest Python builds, while a pinned uv asks for the builds it shipped with; npmmirror keeps every release.
+ $pythonMirror = "$npmMirror/-/binary/python-build-standalone"
$minBps = 1MB
$useUv = -not (Test-MirrorConfigured -Tool uv)
$usePip = -not (Test-MirrorConfigured -Tool pip)
@@ -4692,6 +4710,7 @@ function Install-UnslothStudio {
}
if (-not $env:UNSLOTH_NODE_MIRROR) { $hosts['node'] = @('node', 'npmmirror-node', "$npmMirror/-/binary/node", $null, $null) }
if (-not "$env:UNSLOTH_NPM_REGISTRY$env:NPM_CONFIG_REGISTRY") { $hosts['npm'] = @('npm', 'npmmirror', $npmMirror, $null, $null) }
+ if (-not (Test-MirrorConfigured -Tool python)) { $hosts['python'] = @('astral', 'npmmirror', $pythonMirror, $null, $null) }
if (-not "$env:UNSLOTH_UV_WHEEL_MIRROR$env:UV_DOWNLOAD_URL$env:INSTALLER_DOWNLOAD_URL$env:UV_INSTALLER_GHE_BASE_URL$env:UV_INSTALLER_GITHUB_BASE_URL") {
$hosts['uvbin'] = @('astral', 'cernet-pypi', "$cernet/pypi/web", $null, $null)
}
@@ -4715,6 +4734,7 @@ function Install-UnslothStudio {
'torch' { "UNSLOTH_PYTORCH_MIRROR=$to" }
'node' { "UNSLOTH_NODE_MIRROR=$to" }
'npm' { "UNSLOTH_NPM_REGISTRY=$to" }
+ 'python' { "UV_PYTHON_INSTALL_MIRROR=$to" }
'uvbin' { "UNSLOTH_UV_WHEEL_MIRROR=$to" }
}
}
@@ -4740,7 +4760,7 @@ function Install-UnslothStudio {
if ($slow.Count -eq 0) { return }
$sources = @($slow | ForEach-Object { $hosts[$_][1] } | Select-Object -Unique)
$indexes = Start-MirrorProbe -Urls @($slow | ForEach-Object { $hosts[$_][3]; $hosts[$_][4] } | Where-Object { $_ }) -Seconds 4 -LastByte 1023
- $race = Wait-MirrorProbe (Start-MirrorProbe -Urls @($slow | ForEach-Object { $artifact[$hosts[$_][0]] }; $sources | ForEach-Object { $artifact[$_] }) -Seconds 4 -LastByte 1048575)
+ $race = Wait-MirrorProbe (Start-MirrorProbe -Urls @(@($slow | ForEach-Object { $artifact[$hosts[$_][0]] }) + @($sources | ForEach-Object { $artifact[$_] }) | Select-Object -Unique) -Seconds 4 -LastByte 1048575)
$sourceIndexes = Wait-MirrorProbe $indexes
foreach ($url in $sourceIndexes.Keys) { $answered[$url] = $sourceIndexes[$url] }
} finally {
@@ -4765,7 +4785,7 @@ function Install-UnslothStudio {
function Get-MirrorName {
param([string]$Name)
- @{ pypi = 'PyPI'; unsynced = 'The PyPI mirror'; torch = 'download.pytorch.org'; node = 'nodejs.org'; npm = 'registry.npmjs.org'; uvbin = 'releases.astral.sh (uv)' }[$Name]
+ @{ pypi = 'PyPI'; unsynced = 'The PyPI mirror'; torch = 'download.pytorch.org'; node = 'nodejs.org'; npm = 'registry.npmjs.org'; python = 'releases.astral.sh (Python builds)'; uvbin = 'releases.astral.sh (uv)' }[$Name]
}
function Set-MirrorEnv {
@@ -4797,6 +4817,7 @@ function Install-UnslothStudio {
return
}
if ($Output -match 'download(-r2)?\.pytorch\.org') { 'torch' }
+ elseif ($Output -match 'python-build-standalone') { 'python' }
elseif ($Output -match 'registry\.npmjs\.org') { 'npm' }
elseif ($Output -match 'pypi\.org|pythonhosted\.org') { 'pypi' }
elseif ($Ran -and $Output -notmatch 'https?://') { $Ran }
@@ -4901,10 +4922,10 @@ function Install-UnslothStudio {
}) | ForEach-Object { "$_" }
$torchArg = [bool](@($words) -like 'https://download.pytorch.org/whl*')
$pinned = [bool](@($words) -match '^--(index-url|default-index)$')
- $ran = if ($torchArg) { 'torch' } elseif ($pinned -or @($words) -match '^(--find-links|--no-index|--torch-backend.*|venv)$|://') { '' } else { 'pypi' }
+ $ran = if ($torchArg) { 'torch' } elseif ($pinned -or @($words) -match '^(--find-links|--no-index|--torch-backend.*|venv)$|://') { '' } elseif ($Command.ToString() -match '(^|\s)python\s+install(\s|$)') { 'python' } else { 'pypi' }
$failed = Get-MirrorFailedHost -Output $Output -Ran $ran
$ownIndex = $pinned -or @($words) -contains '--no-index'
- if (-not (($failed -eq 'torch' -and $torchArg) -or ($failed -eq 'pypi' -and -not $pinned) -or ($failed -eq 'unsynced' -and -not $ownIndex))) { return $Code }
+ if (-not (($failed -eq 'torch' -and $torchArg) -or ($failed -eq 'pypi' -and -not $pinned) -or ($failed -eq 'unsynced' -and -not $ownIndex) -or $failed -eq 'python')) { return $Code }
$pairs = @(Pop-MirrorSpare $failed)
if (-not $pairs) { return $Code }
$saved = @{}
@@ -6784,7 +6805,7 @@ exit 0
if ($SkipTorch) { $InitialGpuBranch = "no_torch" }
Write-TauriDiag -GpuBranch $InitialGpuBranch -TorchIndexFamily "none" -PythonVersionForDiag $DiagPythonVersion
- foreach ($_mirrorEnvName in @('_UNSLOTH_MIRROR_PROBED', '_UNSLOTH_MIRROR_SPARE', 'UV_INDEX', 'UV_DEFAULT_INDEX', 'UV_INDEX_STRATEGY', 'PIP_INDEX_URL', 'PIP_EXTRA_INDEX_URL', 'UNSLOTH_PYTORCH_MIRROR', 'UNSLOTH_NODE_MIRROR', 'UNSLOTH_NPM_REGISTRY', 'UNSLOTH_UV_WHEEL_MIRROR')) {
+ foreach ($_mirrorEnvName in @('_UNSLOTH_MIRROR_PROBED', '_UNSLOTH_MIRROR_SPARE', 'UV_INDEX', 'UV_DEFAULT_INDEX', 'UV_INDEX_STRATEGY', 'PIP_INDEX_URL', 'PIP_EXTRA_INDEX_URL', 'UNSLOTH_PYTORCH_MIRROR', 'UNSLOTH_NODE_MIRROR', 'UNSLOTH_NPM_REGISTRY', 'UNSLOTH_UV_WHEEL_MIRROR', 'UV_PYTHON_INSTALL_MIRROR')) {
$script:MirrorEnvSaved[$_mirrorEnvName] = [Environment]::GetEnvironmentVariable($_mirrorEnvName)
}
Invoke-MirrorFallback
@@ -7216,7 +7237,7 @@ exit 0
if ($tried.ContainsKey($version)) { continue }
$tried[$version] = $true
$key = "cpython-$version-windows-$uvArch-none"
- $null = Invoke-InstallCommand -NoMirror -Label "install uv-managed Python $key" {
+ $null = Invoke-InstallCommand -Label "install uv-managed Python $key" {
& $script:UvExe python install --no-bin --no-registry $key
}
# Asked even when the install failed: a runtime installed earlier serves an offline machine.
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index 381eb906e7a..7af6d8d61a6 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -1084,12 +1084,28 @@ function Invoke-ManagedLlamaCppPreflight {
}
function Test-MirrorConfigured {
- param([ValidateSet('uv', 'pip')][string]$Tool)
- if ($Tool -eq 'uv') {
- if ("$env:UV_DEFAULT_INDEX$env:UV_INDEX_URL$env:UV_INDEX$env:UV_EXTRA_INDEX_URL") { return $true }
- $pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
- $files = @($env:UV_CONFIG_FILE, "$env:APPDATA\uv\uv.toml", "$env:ProgramData\uv\uv.toml")
+ param([ValidateSet('uv', 'python', 'pip')][string]$Tool)
+ if ($Tool -ne 'pip') {
+ if ($Tool -eq 'python') {
+ # UV_PYTHON_INSTALL_MIRROR would override UV_ASTRAL_MIRROR_URL; uv rejects a mirror beside a custom manifest.
+ if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL$env:UV_PYTHON_DOWNLOADS_JSON_URL") { return $true }
+ $pattern = '^\s*(python-install-mirror|python-downloads-json-url)\s*='
+ } else {
+ if ("$env:UV_DEFAULT_INDEX$env:UV_INDEX_URL$env:UV_INDEX$env:UV_EXTRA_INDEX_URL") { return $true }
+ $pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)'
+ }
+ # uv's discovery: UV_CONFIG_FILE alone (even with UV_NO_CONFIG); relative paths from --directory.
+ # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper.
+ $uvTrue = @('1', 't', 'true', 'y', 'yes', 'on')
+ $files = @("$env:APPDATA\uv\uv.toml")
+ if ($uvTrue -notcontains "$env:UV_NO_SYSTEM_CONFIG".Trim().ToLowerInvariant()) { $files += "$env:ProgramData\uv\uv.toml" }
$dir = (Get-Location -PSProvider FileSystem).ProviderPath
+ $workDir = if ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY }
+ if ($workDir) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $workDir)) }
+ $configFile = if ($env:UV_CONFIG_FILE) { [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_CONFIG_FILE)) }
+ if ($env:UV_PROJECT) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_PROJECT)) }
+ if ($configFile) { $files = @($configFile); $dir = $null }
+ elseif ($uvTrue -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null }
while ($dir) {
$pyproject = Join-Path $dir 'pyproject.toml'
if (Test-Path -LiteralPath (Join-Path $dir 'uv.toml') -PathType Leaf) { $files += Join-Path $dir 'uv.toml'; break }
@@ -1191,6 +1207,8 @@ function Invoke-MirrorFallback {
$cernet = 'https://tuna.mirrors.cernet.edu.cn'
$npmMirror = 'https://registry.npmmirror.com'
$pypiMirror = "$cernet/pypi/web/simple"
+ # GitHub-release mirrors keep only the newest Python builds, while a pinned uv asks for the builds it shipped with; npmmirror keeps every release.
+ $pythonMirror = "$npmMirror/-/binary/python-build-standalone"
$minBps = 1MB
$useUv = -not (Test-MirrorConfigured -Tool uv)
$usePip = -not (Test-MirrorConfigured -Tool pip)
@@ -1211,6 +1229,7 @@ function Invoke-MirrorFallback {
}
if (-not $env:UNSLOTH_NODE_MIRROR) { $hosts['node'] = @('node', 'npmmirror-node', "$npmMirror/-/binary/node", $null, $null) }
if (-not "$env:UNSLOTH_NPM_REGISTRY$env:NPM_CONFIG_REGISTRY") { $hosts['npm'] = @('npm', 'npmmirror', $npmMirror, $null, $null) }
+ if (-not (Test-MirrorConfigured -Tool python)) { $hosts['python'] = @('astral', 'npmmirror', $pythonMirror, $null, $null) }
if (-not "$env:UNSLOTH_UV_WHEEL_MIRROR$env:UV_DOWNLOAD_URL$env:INSTALLER_DOWNLOAD_URL$env:UV_INSTALLER_GHE_BASE_URL$env:UV_INSTALLER_GITHUB_BASE_URL") {
$hosts['uvbin'] = @('astral', 'cernet-pypi', "$cernet/pypi/web", $null, $null)
}
@@ -1234,6 +1253,7 @@ function Invoke-MirrorFallback {
'torch' { "UNSLOTH_PYTORCH_MIRROR=$to" }
'node' { "UNSLOTH_NODE_MIRROR=$to" }
'npm' { "UNSLOTH_NPM_REGISTRY=$to" }
+ 'python' { "UV_PYTHON_INSTALL_MIRROR=$to" }
'uvbin' { "UNSLOTH_UV_WHEEL_MIRROR=$to" }
}
}
@@ -1259,7 +1279,7 @@ function Invoke-MirrorFallback {
if ($slow.Count -eq 0) { return }
$sources = @($slow | ForEach-Object { $hosts[$_][1] } | Select-Object -Unique)
$indexes = Start-MirrorProbe -Urls @($slow | ForEach-Object { $hosts[$_][3]; $hosts[$_][4] } | Where-Object { $_ }) -Seconds 4 -LastByte 1023
- $race = Wait-MirrorProbe (Start-MirrorProbe -Urls @($slow | ForEach-Object { $artifact[$hosts[$_][0]] }; $sources | ForEach-Object { $artifact[$_] }) -Seconds 4 -LastByte 1048575)
+ $race = Wait-MirrorProbe (Start-MirrorProbe -Urls @(@($slow | ForEach-Object { $artifact[$hosts[$_][0]] }) + @($sources | ForEach-Object { $artifact[$_] }) | Select-Object -Unique) -Seconds 4 -LastByte 1048575)
$sourceIndexes = Wait-MirrorProbe $indexes
foreach ($url in $sourceIndexes.Keys) { $answered[$url] = $sourceIndexes[$url] }
} finally {
@@ -1284,7 +1304,7 @@ function Invoke-MirrorFallback {
function Get-MirrorName {
param([string]$Name)
- @{ pypi = 'PyPI'; unsynced = 'The PyPI mirror'; torch = 'download.pytorch.org'; node = 'nodejs.org'; npm = 'registry.npmjs.org'; uvbin = 'releases.astral.sh (uv)' }[$Name]
+ @{ pypi = 'PyPI'; unsynced = 'The PyPI mirror'; torch = 'download.pytorch.org'; node = 'nodejs.org'; npm = 'registry.npmjs.org'; python = 'releases.astral.sh (Python builds)'; uvbin = 'releases.astral.sh (uv)' }[$Name]
}
function Set-MirrorEnv {
@@ -1316,6 +1336,7 @@ function Get-MirrorFailedHost {
return
}
if ($Output -match 'download(-r2)?\.pytorch\.org') { 'torch' }
+ elseif ($Output -match 'python-build-standalone') { 'python' }
elseif ($Output -match 'registry\.npmjs\.org') { 'npm' }
elseif ($Output -match 'pypi\.org|pythonhosted\.org') { 'pypi' }
elseif ($Ran -and $Output -notmatch 'https?://') { $Ran }
diff --git a/tests/studio/test_mirror_fallback.ps1 b/tests/studio/test_mirror_fallback.ps1
index 45f39b2d331..0a0a0aa1c83 100644
--- a/tests/studio/test_mirror_fallback.ps1
+++ b/tests/studio/test_mirror_fallback.ps1
@@ -58,7 +58,7 @@ try {
$names = '_UNSLOTH_MIRROR_PROBED', 'UNSLOTH_MIRROR_FALLBACK', 'UV_INDEX', 'UV_DEFAULT_INDEX', 'UV_INDEX_URL', 'UV_INDEX_STRATEGY', 'PIP_INDEX_URL',
'PIP_EXTRA_INDEX_URL', 'UNSLOTH_PYTORCH_MIRROR', 'UNSLOTH_NODE_MIRROR', 'UNSLOTH_NPM_REGISTRY', 'NPM_CONFIG_REGISTRY', 'UV_OFFLINE', 'UV_CONFIG_FILE', 'PIP_CONFIG_FILE',
- 'UNSLOTH_UV_WHEEL_MIRROR', 'UV_INSTALLER_GITHUB_BASE_URL', 'UV_INSTALL_DIR', 'UV_NO_MODIFY_PATH', '_UNSLOTH_MIRROR_SPARE', 'UNSLOTH_INSTALL_RETRIES', 'UNSLOTH_INSTALL_RETRY_DELAY'
+ 'UNSLOTH_UV_WHEEL_MIRROR', 'UV_INSTALLER_GITHUB_BASE_URL', 'UV_INSTALL_DIR', 'UV_NO_MODIFY_PATH', '_UNSLOTH_MIRROR_SPARE', 'UNSLOTH_INSTALL_RETRIES', 'UNSLOTH_INSTALL_RETRY_DELAY', 'UV_PYTHON_INSTALL_MIRROR', 'UV_NO_CONFIG', 'UV_ASTRAL_MIRROR_URL', 'UV_NO_SYSTEM_CONFIG', 'UV_PROJECT', 'UV_WORKING_DIR', 'UV_WORKING_DIRECTORY', 'UV_PYTHON_DOWNLOADS_JSON_URL'
$saved = @{}; foreach ($n in $names + 'APPDATA', 'USERPROFILE', 'ProgramData', 'PATH') { $saved[$n] = [Environment]::GetEnvironmentVariable($n) }
$home_ = Join-Path ([System.IO.Path]::GetTempPath()) ("unsloth-mirror-" + [guid]::NewGuid())
$pipIni = Join-Path $home_ 'AppData/pip/pip.ini'
@@ -113,6 +113,7 @@ function Run($mock, $envs = @{}, [switch]$SpareOnly, [switch]$Abroad) {
Invoke-MirrorFallback -SpareOnly:$SpareOnly
}
$pypiMirror = "$M/pypi/web/simple"
+$pythonMirror = 'https://registry.npmmirror.com/-/binary/python-build-standalone'
try {
Run @{}; Check "fast hosts export and print nothing" (-not $env:UV_DEFAULT_INDEX -and -not $env:UNSLOTH_NPM_REGISTRY -and $script:lines.Count -eq 0)
Run @{ pypi = 'blocked'; torch = 'blocked'; npm = 'blocked' } -Abroad
@@ -127,7 +128,7 @@ try {
Check "fast hosts never touch a mirror" (-not ($script:probed -match 'cernet|npmmirror'))
Run @{ pypi = 'slow'; torch = 'slow'; node = 'slow'; npm = 'slow'; astral = 'slow' }; Check "defaults are timed one at a time, on 1 MiB within 1.5 s or 4 s; indexes on 1 KiB within 4 s" (-not $script:overlap -and -not $script:badRange)
Run @{ torch = 'blocked' }
- Check "hosts left on their defaults keep their mirror, blocked-mode, as a spare" ($env:_UNSLOTH_MIRROR_SPARE -eq "pypi|UV_DEFAULT_INDEX=$pypiMirror|PIP_INDEX_URL=$pypiMirror node|UNSLOTH_NODE_MIRROR=https://registry.npmmirror.com/-/binary/node npm|UNSLOTH_NPM_REGISTRY=https://registry.npmmirror.com uvbin|UNSLOTH_UV_WHEEL_MIRROR=$M/pypi/web")
+ Check "hosts left on their defaults keep their mirror, blocked-mode, as a spare" ($env:_UNSLOTH_MIRROR_SPARE -eq "pypi|UV_DEFAULT_INDEX=$pypiMirror|PIP_INDEX_URL=$pypiMirror node|UNSLOTH_NODE_MIRROR=https://registry.npmmirror.com/-/binary/node npm|UNSLOTH_NPM_REGISTRY=https://registry.npmmirror.com python|UV_PYTHON_INSTALL_MIRROR=$pythonMirror uvbin|UNSLOTH_UV_WHEEL_MIRROR=$M/pypi/web")
Run @{ pypi = 'blocked' }
Check "blocked pypi: mirror is the only uv/pip index" ($env:UV_DEFAULT_INDEX -eq $pypiMirror -and $env:PIP_INDEX_URL -eq $pypiMirror -and -not $env:UV_INDEX -and -not $env:UV_INDEX_STRATEGY -and -not $env:PIP_EXTRA_INDEX_URL)
Check "blocked pypi: says so with both speeds and names the opt-out" ($script:lines -contains "STEP PyPI is blocked (0 KB/s, mirror 3906 KB/s); using $pypiMirror" -and $script:lines[-1] -like 'SUBSTEP Set UNSLOTH_MIRROR_FALLBACK=0*')
@@ -186,15 +187,58 @@ try {
Run @{ npm = 'blocked' } @{ UNSLOTH_NPM_REGISTRY = 'https://corp.example/npm/' }; Check "a user npm registry is kept and not probed" ($env:UNSLOTH_NPM_REGISTRY -eq 'https://corp.example/npm/' -and -not ($script:probed -like '*npm*'))
Run @{ pypi = 'blocked' } @{ UNSLOTH_MIRROR_FALLBACK = 'Off' }; Check "UNSLOTH_MIRROR_FALLBACK=Off probes nothing" ($script:probed.Count -eq 0)
Run @{ pypi = 'blocked' } @{ _UNSLOTH_MIRROR_PROBED = '1' }; Check "a parent installer's probe is not repeated" ($script:probed.Count -eq 0)
- Run @{ astral = 'blocked' }; Check "blocked uv releases: the pinned wheel comes from the PyPI mirror" ($env:UNSLOTH_UV_WHEEL_MIRROR -eq "$M/pypi/web"); foreach ($src in 'UV_INSTALLER_GITHUB_BASE_URL', 'UNSLOTH_UV_WHEEL_MIRROR') { Run @{ astral = 'blocked' } @{ $src = 'https://corp.example/uv' }; Check "a user $src skips the uv probe" (-not ($script:probed -like '*releases.astral.sh*')) }
+ Run @{ astral = 'blocked' }; Check "blocked uv releases: the pinned wheel comes from the PyPI mirror" ($env:UNSLOTH_UV_WHEEL_MIRROR -eq "$M/pypi/web"); foreach ($src in 'UV_INSTALLER_GITHUB_BASE_URL', 'UNSLOTH_UV_WHEEL_MIRROR') {
+ Run @{ astral = 'blocked' } @{ $src = 'https://corp.example/uv'; UV_PYTHON_INSTALL_MIRROR = 'https://corp.example/pbs' }; Check "a user $src (and Python mirror) skips the releases.astral.sh probe" (-not ($script:probed -like '*releases.astral.sh*'))
+ Run @{ astral = 'blocked' } @{ $src = 'https://corp.example/uv' }; Check "a user $src keeps uv's source while Python builds still fall back" ($env:_UNSLOTH_MIRROR_SPARE -notmatch 'uvbin' -and $env:UNSLOTH_UV_WHEEL_MIRROR -ne "$M/pypi/web" -and $env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ }
+ Run @{ astral = 'blocked' }; Check "blocked releases.astral.sh: uv's Python builds come from npmmirror, said by name" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror -and $script:lines -contains "STEP releases.astral.sh (Python builds) is blocked (0 KB/s, mirror 3906 KB/s); using $pythonMirror" -and $env:_UNSLOTH_MIRROR_SPARE -notmatch '(^| )python\|')
+ Check "python and uv share the releases.astral.sh probe, raced once" (@($script:probed -like 'https://releases.astral.sh/*').Count -eq 2)
+ Run @{ astral = 'blocked'; npmmirror = 'blocked' }; Check "a dead npmmirror keeps uv's Python builds on the default, spared" (-not $env:UV_PYTHON_INSTALL_MIRROR -and $env:_UNSLOTH_MIRROR_SPARE -like "*python|UV_PYTHON_INSTALL_MIRROR=$pythonMirror*")
+ Run @{ astral = 'blocked' } @{ UV_PYTHON_INSTALL_MIRROR = 'https://corp.example/pbs' }; Check "a user UV_PYTHON_INSTALL_MIRROR is kept, and not spared" ($env:UV_PYTHON_INSTALL_MIRROR -eq 'https://corp.example/pbs' -and $env:_UNSLOTH_MIRROR_SPARE -notmatch 'UV_PYTHON_INSTALL_MIRROR' -and $env:UNSLOTH_UV_WHEEL_MIRROR -eq "$M/pypi/web")
+ Run @{ astral = 'blocked' } @{ UV_ASTRAL_MIRROR_URL = 'https://corp.example/astral' }; Check "a user UV_ASTRAL_MIRROR_URL serves Python builds: no npmmirror override" (-not $env:UV_PYTHON_INSTALL_MIRROR -and $env:_UNSLOTH_MIRROR_SPARE -notmatch 'UV_PYTHON_INSTALL_MIRROR')
+ New-Item -ItemType Directory -Force -Path (Join-Path $env:APPDATA 'uv') | Out-Null
+ Set-Content -Path (Join-Path $env:APPDATA 'uv/uv.toml') -Value 'python-install-mirror = "https://corp.example/pbs"'
+ Run @{ astral = 'blocked'; pypi = 'blocked' }; Check "uv.toml python-install-mirror is kept, the index fallback still on" (-not $env:UV_PYTHON_INSTALL_MIRROR -and $env:_UNSLOTH_MIRROR_SPARE -notmatch 'UV_PYTHON_INSTALL_MIRROR' -and $env:UV_DEFAULT_INDEX -eq $pypiMirror)
+ $customUv = Join-Path $home_ 'custom-uv.toml'; Set-Content -Path $customUv -Value '# no mirror here'
+ Run @{ astral = 'blocked' } @{ UV_CONFIG_FILE = $customUv }; Check "UV_CONFIG_FILE replaces the discovered uv.toml, so its Python mirror does not count" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ Run @{ astral = 'blocked' } @{ UV_NO_CONFIG = '1' }; Check "UV_NO_CONFIG ignores the uv.toml Python mirror" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ Run @{ astral = 'blocked' } @{ UV_NO_CONFIG = 'f' }; Check "UV_NO_CONFIG=f is false to uv, so the uv.toml Python mirror still counts" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ New-Item -ItemType Directory -Force -Path (Join-Path $env:ProgramData 'uv') | Out-Null
+ Set-Content -Path (Join-Path $env:ProgramData 'uv/uv.toml') -Value 'python-install-mirror = "https://corp.example/pbs"'
+ Remove-Item -LiteralPath (Join-Path $env:APPDATA 'uv/uv.toml')
+ Run @{ astral = 'blocked' }; Check "a system uv.toml Python mirror counts" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ Run @{ astral = 'blocked' } @{ UV_NO_SYSTEM_CONFIG = '1' }; Check "UV_NO_SYSTEM_CONFIG ignores the system uv.toml Python mirror" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ Remove-Item -LiteralPath (Join-Path $env:ProgramData 'uv/uv.toml')
+ $proj = Join-Path $home_ 'proj'; New-Item -ItemType Directory -Force -Path $proj | Out-Null
+ Set-Content -Path (Join-Path $proj 'uv.toml') -Value 'python-install-mirror = "https://corp.example/pbs"'
+ foreach ($v in 'UV_PROJECT', 'UV_WORKING_DIR', 'UV_WORKING_DIRECTORY') {
+ Run @{ astral = 'blocked' } @{ $v = $proj }; Check "$v points discovery at a project whose uv.toml has a Python mirror" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ }
+ $other = Join-Path $home_ 'other'; New-Item -ItemType Directory -Force -Path $other | Out-Null
+ Push-Location $home_
+ try {
+ # uv 0.10.7 / 0.12.1 `python install --show-settings`: --directory first, then relative paths from it.
+ Run @{ astral = 'blocked' } @{ UV_PROJECT = 'proj'; UV_WORKING_DIR = $other }; Check "a relative UV_PROJECT resolves from UV_WORKING_DIR, where uv runs" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ Run @{ astral = 'blocked' } @{ UV_PROJECT = 'proj'; UV_WORKING_DIR = $home_ }; Check "UV_WORKING_DIR then UV_PROJECT reaches that project's Python mirror" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ Set-Content -Path (Join-Path $other 'custom.toml') -Value 'python-install-mirror = "https://corp.example/pbs"'
+ Run @{ astral = 'blocked' } @{ UV_CONFIG_FILE = 'custom.toml'; UV_WORKING_DIR = $other }; Check "a relative UV_CONFIG_FILE resolves from UV_WORKING_DIR" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ Run @{ astral = 'blocked' } @{ UV_PYTHON_DOWNLOADS_JSON_URL = 'https://corp.example/downloads.json' }; Check "a custom Python downloads manifest is left alone" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ } finally { Pop-Location }
+ Run @{ astral = 'blocked' }; Check "without it, that project's uv.toml is not in scope" ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ Set-Content -Path (Join-Path $env:APPDATA 'uv/uv.toml') -Value 'python-install-mirror = "https://corp.example/pbs"'
+ Set-Content -Path $customUv -Value 'python-install-mirror = "https://corp.example/pbs"'
+ Run @{ astral = 'blocked' } @{ UV_CONFIG_FILE = $customUv }; Check "a Python mirror in UV_CONFIG_FILE is kept" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ Run @{ astral = 'blocked' } @{ UV_CONFIG_FILE = $customUv; UV_NO_CONFIG = '1' }; Check "UV_CONFIG_FILE is still read with UV_NO_CONFIG" (-not $env:UV_PYTHON_INSTALL_MIRROR)
+ Remove-Item -LiteralPath (Join-Path $env:APPDATA 'uv/uv.toml')
$uvDown = "error: Failed to fetch: ``https://pypi.org/simple/numpy/```n Caused by: error sending request for url (https://pypi.org/simple/numpy/)"
$torchDown = "error: Failed to fetch: ``https://download.pytorch.org/whl/cu128/torch/```n Caused by: operation timed out"
$npmDown = "npm error network request to https://registry.npmjs.org/react failed, reason: read ECONNRESET"
$stall = "error: Failed to download distribution`n Caused by: Failed to download: network timeout"
$pipDown = "WARNING: Retrying (Retry(total=0)) after connection broken by 'ReadTimeoutError(`"HTTPSConnectionPool(host='pypi.org', port=443): Read timed out.`")': /simple/numpy/"
+ $pythonDown = "error: Failed to install cpython-3.12.12-windows-x86_64-none`n Caused by: Failed to download https://releases.astral.sh/github/python-build-standalone/releases/download/20260910/cpython-3.12.12.tar.gz`n Caused by: error decoding response body"
$lag = " cause: Because only unsloth<=2026.9.9 is available and you require unsloth>=2026.9.10, we can conclude that your requirements are unsatisfiable."
$noVersion = "error: No solution found when resolving dependencies: Because nothing==9 was not found in the package registry (https://pypi.org/simple)"
- foreach ($case in @($uvDown, '', 'pypi'), @($torchDown, 'pypi', 'torch'), @($npmDown, '', 'npm'), @($pipDown, '', 'pypi'), @('npm error code ERESOLVE', 'npm', $null), @($stall, 'pypi', 'pypi'), @($stall, '', $null), @($noVersion, 'pypi', 'unsynced'), @($lag, '', 'unsynced'), @('ERROR: No matching distribution found for unsloth>=2026.9.10', '', 'unsynced'), @("$stall (see https://example.com/)", 'pypi', $null)) {
+ foreach ($case in @($uvDown, '', 'pypi'), @($torchDown, 'pypi', 'torch'), @($npmDown, '', 'npm'), @($pipDown, '', 'pypi'), @('npm error code ERESOLVE', 'npm', $null), @($stall, 'pypi', 'pypi'), @($stall, '', $null), @($pythonDown, '', 'python'), @($stall, 'python', 'python'), @($noVersion, 'pypi', 'unsynced'), @($lag, '', 'unsynced'), @('ERROR: No matching distribution found for unsloth>=2026.9.10', '', 'unsynced'), @("$stall (see https://example.com/)", 'pypi', $null)) {
Check "failed host: $($case[1]) ran, output '$($case[0].Split("`n")[-1])' -> $($case[2])" ((Get-MirrorFailedHost -Output $case[0] -Ran $case[1]) -eq $case[2])
}
function Write-TauriLog {}; function Clear-TauriInstallError {}; function Write-UvDownloadMarker {}; function Write-StudioLine {}
@@ -222,6 +266,19 @@ try {
function uv { $script:calls += , "$args"; Write-Error $script:fail; $global:LASTEXITCODE = 1 }
$rc = Retry $uvDown { uv pip install numpy } -Once
Check "a failed mirror rerun restores the default and spends the spare" ($rc -eq 1 -and $script:calls.Count -eq 2 -and -not $env:UV_DEFAULT_INDEX -and -not $env:PIP_INDEX_URL -and $env:_UNSLOTH_MIRROR_SPARE -notlike 'pypi|*')
+ function uv { $script:calls += , "$args"; if ($env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror) { $global:LASTEXITCODE = 0 } else { Write-Error $script:fail; $global:LASTEXITCODE = 1 } }
+ $rc = Retry $pythonDown { uv python install --no-bin --no-registry cpython-3.12.12-windows-x86_64-none } -Once
+ Check "python transport: uv python install reruns once through npmmirror, kept for later installs" ($rc -eq 0 -and $script:calls.Count -eq 2 -and $env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror -and $script:lines -contains "STEP releases.astral.sh (Python builds) failed; retrying through $pythonMirror" -and $env:_UNSLOTH_MIRROR_SPARE -notmatch '(^| )python\|' -and $env:_UNSLOTH_MIRROR_SPARE -like 'pypi|*')
+ $rc = Retry $stall { uv python install --no-bin --no-registry cpython-3.12.12-windows-x86_64-none } -Once
+ Check "python transport: a stall naming no host retries on the Python mirror" ($rc -eq 0 -and $script:calls.Count -eq 2 -and $env:UV_PYTHON_INSTALL_MIRROR -eq $pythonMirror)
+ function uv { $script:calls += , "$args"; Write-Error $script:fail; $global:LASTEXITCODE = 1 }
+ $rc = Retry $pythonDown { uv python install cpython-3.12.12-windows-x86_64-none } -Once; $rc2 = Invoke-InstallCommand -Label t -Command { uv python install cpython-3.12.13-windows-x86_64-none }
+ Check "python transport: a failed mirror rerun restores the default and is not repeated" ($rc -eq 1 -and $rc2 -eq 1 -and $script:calls.Count -eq 3 -and -not $env:UV_PYTHON_INSTALL_MIRROR)
+ Run @{} -Abroad; $script:fail = $pythonDown; $script:calls = @()
+ $rc = Invoke-InstallCommand -Label t -Command { uv python install cpython-3.12.12-windows-x86_64-none }
+ Check "python transport: with the fallback off, one attempt and no mirror" ($rc -eq 1 -and $script:calls.Count -eq 1 -and -not $env:UV_PYTHON_INSTALL_MIRROR)
+ $resolve = $ast.FindAll({ param($n) $n -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $n.Name -eq 'Resolve-UvManagedPython' }, $true)[0].Extent.Text
+ Check "the uv-managed Python install may use the mirror spare" ($resolve -match 'Invoke-InstallCommand -Label "install uv-managed Python' -and $resolve -notmatch '-NoMirror')
function uv { $script:calls += , "$args"; if ("$args" -match 'download\.pytorch') { Write-Error $script:fail; $global:LASTEXITCODE = 1 } else { $global:LASTEXITCODE = 0 } }
$TorchIndexUrl = 'https://download.pytorch.org/whl/cu128'; $specs = @('torch', 'https://download.pytorch.org/whl/cu128/xformers.whl')
$env:_UNSLOTH_MIRROR_SPARE = "pypi|UV_DEFAULT_INDEX=$pypiMirror torch|UNSLOTH_PYTORCH_MIRROR=$M/pytorch/whl"; $script:fail = $torchDown; $script:calls = @()