fix setup: fish alias, venv no activate

This commit is contained in:
Shine1i 2026-02-15 16:27:44 +01:00
commit 184b786116

View file

@ -81,13 +81,17 @@ echo "✅ Frontend built to studio/frontend/dist"
# ── 6. Python venv + deps ──
echo ""
echo "Setting up Python environment..."
python3 -m venv .venv
source .venv/bin/activate
run_quiet "pip upgrade" pip install --upgrade pip
if [ ! -d "$SCRIPT_DIR/.venv" ]; then
python3 -m venv "$SCRIPT_DIR/.venv"
fi
# Avoid shell-specific activation; call venv python directly.
VENV_PY="$SCRIPT_DIR/.venv/bin/python"
run_quiet "pip upgrade" "$VENV_PY" -m pip install --upgrade pip
echo " Installing unsloth-zoo + unsloth..."
run_quiet "pip install unsloth" pip install unsloth-zoo unsloth
run_quiet "pip install unsloth" "$VENV_PY" -m pip install unsloth-zoo unsloth
echo " Installing studio dependencies..."
run_quiet "pip install extras" pip install typer fastapi uvicorn pydantic matplotlib pandas nest_asyncio "datasets==4.3.0" pyjwt easydict addict
run_quiet "pip install extras" "$VENV_PY" -m pip install typer fastapi uvicorn pydantic matplotlib pandas nest_asyncio "datasets==4.3.0" pyjwt easydict addict
echo "✅ Python dependencies installed"
# ── 7. Add shell alias ──
@ -95,23 +99,56 @@ echo "✅ Python dependencies installed"
# This alias hardcodes the venv python path so users don't need to activate.
echo ""
REPO_DIR="$SCRIPT_DIR"
ALIAS_CMD="${REPO_DIR}/.venv/bin/python ${REPO_DIR}/cli.py ui -f ${REPO_DIR}/studio/frontend/dist"
if ! grep -qF "unsloth-ui" ~/.bashrc 2>/dev/null; then
cat >> ~/.bashrc <<UNSLOTH_EOF
SHELL_RC_HINT="source ~/.bashrc"
if [[ "${SHELL:-}" == *fish ]]; then
FISH_RC="$HOME/.config/fish/config.fish"
mkdir -p "$(dirname "$FISH_RC")"
if ! grep -qF "unsloth-ui" "$FISH_RC" 2>/dev/null; then
cat >> "$FISH_RC" <<UNSLOTH_EOF
# Unsloth Studio launcher
alias unsloth-ui='${REPO_DIR}/.venv/bin/python ${REPO_DIR}/cli.py ui -f ${REPO_DIR}/studio/frontend/dist'
alias unsloth-ui='${ALIAS_CMD}'
UNSLOTH_EOF
echo "✅ Alias 'unsloth-ui' added to ~/.bashrc"
echo "✅ Alias 'unsloth-ui' added to $FISH_RC"
else
echo "✅ Alias 'unsloth-ui' already exists in $FISH_RC"
fi
SHELL_RC_HINT="source $FISH_RC"
elif [[ "${SHELL:-}" == *zsh ]]; then
ZSH_RC="$HOME/.zshrc"
if ! grep -qF "unsloth-ui" "$ZSH_RC" 2>/dev/null; then
cat >> "$ZSH_RC" <<UNSLOTH_EOF
# Unsloth Studio launcher
alias unsloth-ui='${ALIAS_CMD}'
UNSLOTH_EOF
echo "✅ Alias 'unsloth-ui' added to $ZSH_RC"
else
echo "✅ Alias 'unsloth-ui' already exists in $ZSH_RC"
fi
SHELL_RC_HINT="source $ZSH_RC"
else
echo "✅ Alias 'unsloth-ui' already exists in ~/.bashrc"
BASH_RC="$HOME/.bashrc"
if ! grep -qF "unsloth-ui" "$BASH_RC" 2>/dev/null; then
cat >> "$BASH_RC" <<UNSLOTH_EOF
# Unsloth Studio launcher
alias unsloth-ui='${ALIAS_CMD}'
UNSLOTH_EOF
echo "✅ Alias 'unsloth-ui' added to $BASH_RC"
else
echo "✅ Alias 'unsloth-ui' already exists in $BASH_RC"
fi
SHELL_RC_HINT="source $BASH_RC"
fi
echo ""
echo "╔══════════════════════════════════════╗"
echo "║ Setup Complete! ║"
echo "╠══════════════════════════════════════╣"
echo "║ Run 'source ~/.bashrc' or open a ║"
echo "║ Run '$SHELL_RC_HINT' or open a ║"
echo "║ new terminal, then launch with: ║"
echo "║ ║"
echo "║ unsloth-ui -H 0.0.0.0 -p 8000 ║"