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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep the upgrade intent when the pip fallback runs (#8112)
Daniel Han310a4b5b400f
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex 0e04ca8769a..903ef224ab7 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -3508,18 +3508,34 @@ def _translate_pip_args_for_uv(args: tuple[str, ...]) -> list[str]:def _build_pip_cmd(args: tuple[str, ...]) -> list[str]:"""Build a standard pip install command.- Strips uv-only flags like --upgrade-package that pip doesn't understand.+ pip has no --upgrade-package, so uv's flag is translated rather than+ dropped. Dropping it made this fallback a no-op on the update path:+ `studio update` passes --upgrade-package unsloth with a base.txt that lists+ a bare unsloth, so pip found the requirement already satisfied, installed+ nothing, and the update still reported success. Any uv failure reached that,+ not just the Windows in-use launcher.++ --upgrade-strategy is pinned to only-if-needed rather than left to pip's+ default, because that default is the load-bearing part: it upgrades the+ named packages without dragging the existing torch build along."""cmd = [sys.executable, "-m", "pip", "install"]+ upgrade: list[str] = []skip_next = Falsefor arg in args:if skip_next:skip_next = False+ upgrade.append(arg)continueif arg == "--upgrade-package":- skip_next = True # skip the flag and its value+ skip_next = True # the flag; its value is the package to upgradecontinuecmd.append(arg)+ if upgrade:+ cmd += ["--upgrade", "--upgrade-strategy", "only-if-needed"]+ # Every current caller also names these as positionals or via -r, but a+ # future one might not, and pip would then upgrade nothing.+ cmd += [name for name in upgrade if name not in cmd]return cmddiff --git a/tests/python/test_install_python_stack.py b/tests/python/test_install_python_stack.pyindex 9895e4ddefc..3151067973f 100644--- a/tests/python/test_install_python_stack.py+++ b/tests/python/test_install_python_stack.py@@ -511,3 +511,34 @@ class TestProgressLineNotes:and any(isinstance(t, ast.Name) and t.id == "_PROGRESS_LINE_ACTIVE" for t in n.targets)for n in ast.walk(fn)), "install_python_stack() must reset _PROGRESS_LINE_ACTIVE"+++class TestBuildPipCmdUpgradeIntent:+ """pip has no --upgrade-package, so uv's flag must be translated, not dropped.++ Dropping it made the fallback a no-op on the update path: `studio update`+ passes --upgrade-package unsloth with a base.txt listing a bare unsloth, so+ pip found it satisfied, installed nothing, and the update reported success.+ """++ def test_update_path_keeps_the_upgrade_intent(self):+ cmd = ips._build_pip_cmd(+ ("--no-cache-dir", "--upgrade-package", "unsloth", "--upgrade-package", "unsloth-zoo")+ )+ assert "--upgrade" in cmd+ assert "unsloth" in cmd and "unsloth-zoo" in cmd+ assert "--upgrade-package" not in cmd, "pip does not understand the uv flag"++ def test_torch_is_not_dragged_along(self):+ # only-if-needed is pip's current default, but it is the load-bearing+ # part: eager would re-resolve the existing torch build.+ cmd = ips._build_pip_cmd(("--upgrade-package", "unsloth"))+ assert cmd[cmd.index("--upgrade-strategy") + 1] == "only-if-needed"++ def test_names_already_present_are_not_duplicated(self):+ cmd = ips._build_pip_cmd(("--no-deps", "--upgrade-package", "unsloth", "unsloth"))+ assert cmd.count("unsloth") == 1++ def test_commands_without_the_flag_are_untouched(self):+ cmd = ips._build_pip_cmd(("--no-cache-dir", "somepackage"))+ assert cmd == [sys.executable, "-m", "pip", "install", "--no-cache-dir", "somepackage"]