Skip to content

Instantly share code, notes, and snippets.

@rene-d
Last active July 17, 2026 12:12
Show Gist options
  • Select an option

  • Save rene-d/ff35ebbefad29f6cb6d8f5af33e7e328 to your computer and use it in GitHub Desktop.

Select an option

Save rene-d/ff35ebbefad29f6cb6d8f5af33e7e328 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# ============================================================
# build_litellm_portable_macos.sh
# Construit LiteLLMPortable\ (cible Windows x64) DEPUIS macOS.
# Resolution des dependances pour la PLATEFORME CIBLE via
# uv pip compile --python-platform windows (les marqueurs
# sys_platform/platform_system sont evalues pour Windows,
# pas pour macOS : uvloop exclu, colorama inclus, etc.),
# puis pip download/install en --no-deps sur le lockfile.
# Prerequis : uv, python3 + pip, curl, unzip.
# ============================================================
set -euo pipefail
PYVER=3.13.14
PYTAG=313
LITELLM_PIN="litellm[proxy]==1.91.3"
WHEELS="${WHEELS:-$PWD/wheels}"
ROOT="$PWD/LiteLLMPortable"
PY="$ROOT/App/python"
LOCK="$PWD/win-requirements.txt"
XPLAT=(--platform win_amd64 --python-version "$PYTAG" --implementation cp --only-binary=:all:)
command -v uv >/dev/null || { echo "[ERREUR] uv requis (brew install uv)"; exit 1; }
[ -e "$ROOT" ] && { echo "[ERREUR] $ROOT existe deja"; exit 1; }
echo "[1/6] Resolution des dependances pour Windows/cp$PYTAG (uv)..."
printf '%s\n' "$LITELLM_PIN" > requirements.in
uv pip compile requirements.in -o "$LOCK" \
--python-platform windows --python-version 3.13 --no-build
echo "[2/6] Telechargement des wheels (miroir auditable)..."
mkdir -p "$WHEELS"
python3 -m pip download -r "$LOCK" -d "$WHEELS" --no-deps "${XPLAT[@]}"
echo "[3/6] Python embeddable $PYVER..."
curl -L -o /tmp/pyembed.zip \
"https://www.python.org/ftp/python/$PYVER/python-$PYVER-embed-amd64.zip"
mkdir -p "$PY" "$ROOT/Data/tiktoken"
unzip -q /tmp/pyembed.zip -d "$PY"
echo "[4/6] Activation de site-packages (._pth, CRLF)..."
printf 'python%s.zip\r\n.\r\nLib\\site-packages\r\nimport site\r\n' "$PYTAG" \
> "$PY/python$PYTAG._pth"
echo "[5/6] Installation du lockfile dans le site-packages cible..."
python3 -m pip install -r "$LOCK" --no-deps --target "$PY/Lib/site-packages" \
"${XPLAT[@]}" --no-index --find-links "$WHEELS" --no-compile
echo "[6/6] Launchers et config..."
cat > "$ROOT/launch.py" <<'EOF'
import sys
from importlib.metadata import entry_points
eps = entry_points(group="console_scripts")
ep = next(e for e in eps if e.name == "litellm")
sys.exit(ep.load()())
EOF
# litellm.cmd : genere en CRLF (cmd.exe est capricieux avec LF seul)
printf '%s\r\n' \
'@echo off' \
'setlocal' \
'set "ROOT=%~dp0"' \
'set PYTHONNOUSERSITE=1' \
'set PYTHONDONTWRITEBYTECODE=1' \
'set "HOME=%ROOT%Data"' \
'set "USERPROFILE=%ROOT%Data"' \
'set "TIKTOKEN_CACHE_DIR=%ROOT%Data\tiktoken"' \
'"%ROOT%App\python\python.exe" "%ROOT%launch.py" %*' \
> "$ROOT/litellm.cmd"
cat > "$ROOT/Data/config.yaml" <<'EOF'
model_list:
- model_name: exemple
litellm_params:
model: openai/mistral-large
api_base: https://gateway.example.com/v1
api_key: os.environ/GATEWAY_API_KEY
EOF
echo
echo "OK : $ROOT pret (cible win_amd64, cp$PYTAG, lockfile: $LOCK)."
echo "A valider sur une machine Windows : litellm.cmd --version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment