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.

setup.sh: keep the replaced-script handoff directly behind the dependency pass (#15747)

Daniel Han4b71ee393d12
diff --git a/studio/setup.sh b/studio/setup.sh
index 2ca675e3e86..772a4be3383 100755
--- a/studio/setup.sh
+++ b/studio/setup.sh
@@ -3398,8 +3398,9 @@ fi
if [ "$_SKIP_PYTHON_DEPS" = false ]; then
install_python_stack
- _SETUP_VENV_CHANGED=true
_setup_rerun_if_replaced
+ # After the handoff: a replaced copy precompiles on UNSLOTH_SETUP_RERUN, this one on the flag.
+ _SETUP_VENV_CHANGED=true
else
step "python" "dependencies up to date"
verbose_substep "python deps check: installed=$_PKG_NAME@${INSTALLED_VER:-unknown} latest=${LATEST_VER:-unknown}"
diff --git a/tests/python/test_installer_compile_bytecode.py b/tests/python/test_installer_compile_bytecode.py
index 0a97741d353..eb359d7d4bd 100644
--- a/tests/python/test_installer_compile_bytecode.py
+++ b/tests/python/test_installer_compile_bytecode.py
@@ -94,8 +94,13 @@ def _snapshot(root: Path) -> dict:
def test_setup_sh_marks_the_deps_pass_and_compiles_before_the_footer():
lines = _lines(SETUP_SH)
stack = _index(lines, r"^ install_python_stack$")
- assert lines[stack + 1] == " _SETUP_VENV_CHANGED=true"
- assert lines[stack + 2] == " _setup_rerun_if_replaced"
+ # The handoff stays directly behind the dependency pass (tests/sh/test_setup_rerun_after_replace.sh);
+ # the flag follows it inside the same branch, and a replaced copy compiles on UNSLOTH_SETUP_RERUN.
+ assert lines[stack + 1] == " _setup_rerun_if_replaced"
+ flag = _index(lines, r"^ _SETUP_VENV_CHANGED=true$", stack)
+ assert flag <= stack + 3 and lines[flag - 1].lstrip().startswith(
+ ("#", "_setup_rerun_if_replaced")
+ )
assert _index(lines, r"^_SETUP_VENV_CHANGED=false$") < stack
block = _index(lines, r"_SETUP_VENV_CHANGED:-false")
call = _index(lines, r'"\$VENV_DIR/bin/python" -I "\$SCRIPT_DIR/precompile_bytecode.py"', block)