-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
gate on min uv version and shortcut python candidate search if known #4489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6d30c50
gate on min uv version and shortcut python candidate search if known
mmathew23 6dbb63e
Merge branch 'main' into fix/install_minuv
danielhanchen 885bf73
fix sort -V cross compat issue, run_quiet early exit on llamacpp, aut…
mmathew23 6c66a4f
update launch message
mmathew23 ede2867
Fix PR comments
mmathew23 b33a0cc
auto launch and find open port
mmathew23 06749a3
remove dev install
mmathew23 1111c25
Fix review findings: major-version guard, non-fatal port fallback, tt…
danielhanchen 2164ba7
Merge branch 'main' into fix/install_minuv
danielhanchen 59fd922
Remove autolaunch, clean up dead state and debug noise
danielhanchen 4db3bef
Reject prerelease uv at exact minimum version boundary
danielhanchen 2d31fd4
Remove 2>/dev/null from version_ge numeric comparisons
danielhanchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,22 +8,42 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |||||||||||||||||||||
| REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # ── Helper: run command quietly, show output only on failure ── | ||||||||||||||||||||||
| run_quiet() { | ||||||||||||||||||||||
| local label="$1" | ||||||||||||||||||||||
| shift | ||||||||||||||||||||||
| _run_quiet() { | ||||||||||||||||||||||
| local on_fail=$1 | ||||||||||||||||||||||
| local label=$2 | ||||||||||||||||||||||
| shift 2 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| local tmplog | ||||||||||||||||||||||
| tmplog=$(mktemp) | ||||||||||||||||||||||
| if "$@" > "$tmplog" 2>&1; then | ||||||||||||||||||||||
| tmplog=$(mktemp) || { | ||||||||||||||||||||||
| printf '%s\n' "Failed to create temporary file" >&2 | ||||||||||||||||||||||
| [ "$on_fail" = "exit" ] && exit 1 || return 1 | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if "$@" >"$tmplog" 2>&1; then | ||||||||||||||||||||||
| rm -f "$tmplog" | ||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| local exit_code=$? | ||||||||||||||||||||||
| echo "❌ $label failed (exit code $exit_code):" | ||||||||||||||||||||||
| cat "$tmplog" | ||||||||||||||||||||||
| printf 'Failed: %s (exit code %s):\n' "$label" "$exit_code" >&2 | ||||||||||||||||||||||
| cat "$tmplog" >&2 | ||||||||||||||||||||||
| rm -f "$tmplog" | ||||||||||||||||||||||
| exit $exit_code | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ "$on_fail" = "exit" ]; then | ||||||||||||||||||||||
| exit "$exit_code" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| return "$exit_code" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| run_quiet() { | ||||||||||||||||||||||
| _run_quiet exit "$@" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| run_quiet_no_exit() { | ||||||||||||||||||||||
| _run_quiet return "$@" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "╔══════════════════════════════════════╗" | ||||||||||||||||||||||
| echo "║ Unsloth Studio Setup Script ║" | ||||||||||||||||||||||
| echo "╚══════════════════════════════════════╝" | ||||||||||||||||||||||
|
|
@@ -187,9 +207,24 @@ fi | |||||||||||||||||||||
| MIN_PY_MINOR=11 # minimum minor version (>= 3.11) | ||||||||||||||||||||||
| MAX_PY_MINOR=13 # maximum minor version (< 3.14) | ||||||||||||||||||||||
| BEST_PY="" | ||||||||||||||||||||||
| BEST_MAJOR=0 | ||||||||||||||||||||||
| BEST_MINOR=0 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # If the caller (e.g. install.sh) already chose a Python, use it directly. | ||||||||||||||||||||||
| if [ -n "${REQUESTED_PYTHON_VERSION:-}" ] && [ -x "$REQUESTED_PYTHON_VERSION" ]; then | ||||||||||||||||||||||
| _req_ver=$("$REQUESTED_PYTHON_VERSION" --version 2>&1 | awk '{print $2}') | ||||||||||||||||||||||
| _req_major=$(echo "$_req_ver" | cut -d. -f1) | ||||||||||||||||||||||
| _req_minor=$(echo "$_req_ver" | cut -d. -f2) | ||||||||||||||||||||||
| if [ "$_req_major" -eq 3 ] 2>/dev/null && \ | ||||||||||||||||||||||
| [ "$_req_minor" -ge "$MIN_PY_MINOR" ] 2>/dev/null && \ | ||||||||||||||||||||||
| [ "$_req_minor" -le "$MAX_PY_MINOR" ] 2>/dev/null; then | ||||||||||||||||||||||
|
Comment on lines
+214
to
+219
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [8/8 reviewers] High -- Extract
Suggested change
|
||||||||||||||||||||||
| BEST_PY="$REQUESTED_PYTHON_VERSION" | ||||||||||||||||||||||
| echo "Using requested Python version: $BEST_PY" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| echo "Ignoring requested Python $REQUESTED_PYTHON_VERSION ($_req_ver) -- outside supported range" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ -z "$BEST_PY" ]; then | ||||||||||||||||||||||
| # Collect candidate python3 binaries (python3, python3.9, python3.10, …) | ||||||||||||||||||||||
| for candidate in $(compgen -c python3 2>/dev/null | grep -E '^python3(\.[0-9]+)?$' | sort -u); do | ||||||||||||||||||||||
| if ! command -v "$candidate" &>/dev/null; then | ||||||||||||||||||||||
|
|
@@ -206,7 +241,7 @@ for candidate in $(compgen -c python3 2>/dev/null | grep -E '^python3(\.[0-9]+)? | |||||||||||||||||||||
| continue | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Skip versions below 3.12 (require > 3.11) | ||||||||||||||||||||||
| # Skip versions below 3.11 | ||||||||||||||||||||||
| if [ "$py_minor" -lt "$MIN_PY_MINOR" ] 2>/dev/null; then | ||||||||||||||||||||||
| continue | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
@@ -219,11 +254,11 @@ for candidate in $(compgen -c python3 2>/dev/null | grep -E '^python3(\.[0-9]+)? | |||||||||||||||||||||
| # Keep the highest qualifying version | ||||||||||||||||||||||
| if [ "$py_minor" -gt "$BEST_MINOR" ]; then | ||||||||||||||||||||||
| BEST_PY="$candidate" | ||||||||||||||||||||||
| BEST_MAJOR="$py_major" | ||||||||||||||||||||||
| BEST_MINOR="$py_minor" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
| echo "finished finding best python" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ -z "$BEST_PY" ]; then | ||||||||||||||||||||||
| echo "❌ ERROR: No Python version between 3.${MIN_PY_MINOR} and 3.${MAX_PY_MINOR} found on this system." | ||||||||||||||||||||||
| echo " Detected Python 3 installations:" | ||||||||||||||||||||||
|
|
@@ -402,7 +437,7 @@ rm -rf "$LLAMA_CPP_DIR" | |||||||||||||||||||||
| echo "Building llama-server for GGUF inference..." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| BUILD_OK=true | ||||||||||||||||||||||
| run_quiet "clone llama.cpp" git clone --depth 1 https://github.com/ggml-org/llama.cpp.git "$LLAMA_CPP_DIR" || BUILD_OK=false | ||||||||||||||||||||||
| run_quiet_no_exit "clone llama.cpp" git clone --depth 1 https://github.com/ggml-org/llama.cpp.git "$LLAMA_CPP_DIR" || BUILD_OK=false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ "$BUILD_OK" = true ]; then | ||||||||||||||||||||||
| # Skip tests/examples we don't need (faster build) | ||||||||||||||||||||||
|
|
@@ -474,16 +509,16 @@ rm -rf "$LLAMA_CPP_DIR" | |||||||||||||||||||||
| CMAKE_GENERATOR_ARGS="-G Ninja" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| run_quiet "cmake llama.cpp" cmake $CMAKE_GENERATOR_ARGS -S "$LLAMA_CPP_DIR" -B "$LLAMA_CPP_DIR/build" $CMAKE_ARGS || BUILD_OK=false | ||||||||||||||||||||||
| run_quiet_no_exit "cmake llama.cpp" cmake $CMAKE_GENERATOR_ARGS -S "$LLAMA_CPP_DIR" -B "$LLAMA_CPP_DIR/build" $CMAKE_ARGS || BUILD_OK=false | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ "$BUILD_OK" = true ]; then | ||||||||||||||||||||||
| run_quiet "build llama-server" cmake --build "$LLAMA_CPP_DIR/build" --config Release --target llama-server -j"$NCPU" || BUILD_OK=false | ||||||||||||||||||||||
| run_quiet_no_exit "build llama-server" cmake --build "$LLAMA_CPP_DIR/build" --config Release --target llama-server -j"$NCPU" || BUILD_OK=false | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Also build llama-quantize (needed by unsloth-zoo's GGUF export pipeline) | ||||||||||||||||||||||
| if [ "$BUILD_OK" = true ]; then | ||||||||||||||||||||||
| run_quiet "build llama-quantize" cmake --build "$LLAMA_CPP_DIR/build" --config Release --target llama-quantize -j"$NCPU" || true | ||||||||||||||||||||||
| run_quiet_no_exit "build llama-quantize" cmake --build "$LLAMA_CPP_DIR/build" --config Release --target llama-quantize -j"$NCPU" || true | ||||||||||||||||||||||
| # Symlink to llama.cpp root — check_llama_cpp() looks for the binary there | ||||||||||||||||||||||
| QUANTIZE_BIN="$LLAMA_CPP_DIR/build/bin/llama-quantize" | ||||||||||||||||||||||
| if [ -f "$QUANTIZE_BIN" ]; then | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
set -euo pipefail, the command substitution$("$REQUESTED_PYTHON_VERSION" --version ...)will terminate the whole script if that executable exits non-zero. That means a bad-but-executableREQUESTED_PYTHON_VERSION(for example a wrapper script that fails at runtime) now aborts setup before the existing fallback search can run, even though other valid Python 3.11–3.13 interpreters may be available.Useful? React with 👍 / 👎.