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.

fix: [Studio] setup.ps1 update-flow for windows (#4667)

Roland Tannous5bbfabb15109
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index 8a1ae4b237f..9a1d332a606 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -1351,7 +1351,30 @@ function Fast-Install {
& python -m pip install @Args_ 2>&1
}
-Fast-Install --upgrade pip | Out-Null
+# ── Check if Python deps need updating ──
+# Compare installed package version against PyPI latest.
+# Skip all Python dependency work if versions match (fast update path).
+$_PkgName = if ($env:STUDIO_PACKAGE_NAME) { $env:STUDIO_PACKAGE_NAME } else { "unsloth" }
+$SkipPythonDeps = $false
+
+if ($env:SKIP_STUDIO_BASE -ne "1" -and $env:STUDIO_LOCAL_INSTALL -ne "1") {
+ # Only check when NOT called from install.ps1 (which just installed the package)
+ $InstalledVer = try { (& python -c "from importlib.metadata import version; print(version('$_PkgName'))" 2>$null | Out-String).Trim() } catch { "" }
+ $LatestVer = ""
+ try {
+ $pypiJson = Invoke-RestMethod -Uri "https://pypi.org/pypi/$_PkgName/json" -TimeoutSec 5 -ErrorAction Stop
+ $LatestVer = "$($pypiJson.info.version)".Trim()
+ } catch { }
+
+ if ($InstalledVer -and $LatestVer -and ($InstalledVer -eq $LatestVer)) {
+ step "python" "$_PkgName $InstalledVer is up to date"
+ $SkipPythonDeps = $true
+ } elseif ($InstalledVer -and $LatestVer) {
+ substep "$_PkgName $InstalledVer -> $LatestVer available, updating..."
+ } elseif (-not $LatestVer) {
+ substep "could not reach PyPI, updating to be safe..."
+ }
+}
# if (-not $IsPipInstall) {
# # Running from repo: copy requirements and do editable install
@@ -1371,6 +1394,10 @@ Fast-Install --upgrade pip | Out-Null
# pip install unsloth-roland-test 2>&1 | Out-Null
# }
+if (-not $SkipPythonDeps) {
+
+Fast-Install --upgrade pip | Out-Null
+
# Pre-install PyTorch with CUDA support.
# On Windows, the default PyPI torch wheel is CPU-only.
# We need PyTorch's CUDA index to get GPU-enabled wheels.
@@ -1456,6 +1483,12 @@ if ($LASTEXITCODE -ne 0) {
$ErrorActionPreference = $prevEAP_t5
step "transformers" "5.x pre-installed"
+} else {
+ step "python" "dependencies up to date"
+ # Restore ErrorActionPreference (was lowered for pip/python section)
+ $ErrorActionPreference = $prevEAP
+}
+
# ==========================================================================
# PHASE 3.4: Prefer prebuilt llama.cpp bundles before source build
# ==========================================================================
@@ -1877,13 +1910,14 @@ if (-not $NeedLlamaSourceBuild) {
# ─────────────────────────────────────────────
# Footer
# ─────────────────────────────────────────────
+$DoneLabel = if ($env:SKIP_STUDIO_BASE -eq "1") { "Unsloth Studio Setup Complete" } else { "Unsloth Studio Updated" }
if ($script:StudioVtOk -and -not $env:NO_COLOR) {
Write-Host (" {0}{1}{2}" -f (Get-StudioAnsi Dim), $Rule, (Get-StudioAnsi Reset))
- Write-Host (" " + (Get-StudioAnsi Title) + "Unsloth Studio Installed" + (Get-StudioAnsi Reset))
+ Write-Host (" " + (Get-StudioAnsi Title) + $DoneLabel + (Get-StudioAnsi Reset))
Write-Host (" {0}{1}{2}" -f (Get-StudioAnsi Dim), $Rule, (Get-StudioAnsi Reset))
} else {
Write-Host " $Rule" -ForegroundColor DarkGray
- Write-Host " Unsloth Studio Installed" -ForegroundColor Green
+ Write-Host " $DoneLabel" -ForegroundColor Green
Write-Host " $Rule" -ForegroundColor DarkGray
}
step "launch" "unsloth studio -H 0.0.0.0 -p 8888"
diff --git a/unsloth_cli/commands/studio.py b/unsloth_cli/commands/studio.py
index f56f582c14b..135fa4c3bff 100644
--- a/unsloth_cli/commands/studio.py
+++ b/unsloth_cli/commands/studio.py
@@ -290,13 +290,18 @@ def update(
),
):
"""Update Unsloth Studio dependencies and rebuild."""
- os.environ["STUDIO_LOCAL_INSTALL"] = "1" if local else "0"
+ # Ensure SKIP_STUDIO_BASE is not inherited from a parent install.ps1 session
+ os.environ.pop("SKIP_STUDIO_BASE", None)
os.environ["STUDIO_PACKAGE_NAME"] = package
if local:
+ os.environ["STUDIO_LOCAL_INSTALL"] = "1"
# Pass the repo root explicitly so install_python_stack.py doesn't
# have to guess from SCRIPT_DIR (which may be inside site-packages).
repo_root = Path(__file__).resolve().parents[2]
os.environ["STUDIO_LOCAL_REPO"] = str(repo_root)
+ else:
+ os.environ["STUDIO_LOCAL_INSTALL"] = "0"
+ os.environ.pop("STUDIO_LOCAL_REPO", None)
_run_setup_script(verbose = verbose)