Created
July 16, 2026 13:16
-
-
Save rene-d/ba2703d9cd8899ca0a21f80880e8e9f5 to your computer and use it in GitHub Desktop.
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
| @echo off | |
| setlocal EnableExtensions | |
| :: ============================================================ | |
| :: build_litellm_portable.bat -- 100%% OFFLINE | |
| :: Construit .\LiteLLMPortable\ a partir de C:\wheels | |
| :: La version de Python est lue dans C:\wheels\PYVER.txt | |
| :: (ecrit par prep_wheels.bat) : une seule source de verite. | |
| :: ============================================================ | |
| set "WHEELS=C:\wheels" | |
| if not exist "%WHEELS%\PYVER.txt" ( | |
| echo [ERREUR] %WHEELS%\PYVER.txt introuvable - lancez prep_wheels.bat d'abord | |
| exit /b 1 | |
| ) | |
| set /p PYVER=<"%WHEELS%\PYVER.txt" | |
| for /f "tokens=1,2 delims=." %%a in ("%PYVER%") do set "PYTAG=%%a%%b" | |
| set "PYZIP=python-%PYVER%-embed-amd64.zip" | |
| set "ROOT=%~dp0LiteLLMPortable" | |
| set "PY=%ROOT%\App\python" | |
| :: --- verifications prealables --- | |
| if not exist "%WHEELS%\%PYZIP%" ( | |
| echo [ERREUR] %WHEELS%\%PYZIP% introuvable | |
| exit /b 1 | |
| ) | |
| if not exist "%WHEELS%\get-pip.py" ( | |
| echo [ERREUR] %WHEELS%\get-pip.py introuvable | |
| exit /b 1 | |
| ) | |
| if exist "%ROOT%" ( | |
| echo [ERREUR] %ROOT% existe deja - supprimez-le d'abord | |
| exit /b 1 | |
| ) | |
| mkdir "%PY%" || exit /b 1 | |
| mkdir "%ROOT%\Data" | |
| echo [1/6] Extraction du Python embeddable %PYVER%... | |
| powershell -NoProfile -Command "Expand-Archive -LiteralPath '%WHEELS%\%PYZIP%' -DestinationPath '%PY%'" | |
| if errorlevel 1 exit /b 1 | |
| echo [2/6] Activation de site-packages (fichier ._pth)... | |
| ( | |
| echo python%PYTAG%.zip | |
| echo . | |
| echo Lib\site-packages | |
| echo import site | |
| ) > "%PY%\python%PYTAG%._pth" | |
| echo [3/6] Installation de pip (offline)... | |
| "%PY%\python.exe" "%WHEELS%\get-pip.py" --no-index --find-links "%WHEELS%" --no-warn-script-location | |
| if errorlevel 1 exit /b 1 | |
| echo [4/6] Installation de litellm[proxy] (offline)... | |
| "%PY%\python.exe" -m pip install "litellm[proxy]" --no-index --find-links "%WHEELS%" --only-binary=:all: --no-warn-script-location | |
| if errorlevel 1 exit /b 1 | |
| echo [5/6] Generation des launchers et de la config... | |
| :: launch.py : resout l'entry point "litellm" via les metadonnees | |
| ( | |
| echo import sys | |
| echo from importlib.metadata import entry_points | |
| echo. | |
| echo eps = entry_points^(group="console_scripts"^) | |
| echo ep = next^(e for e in eps if e.name == "litellm"^) | |
| echo sys.exit^(ep.load^(^)^(^)^) | |
| ) > "%ROOT%\launch.py" | |
| :: litellm.cmd : launcher relocalisable (tout en chemins relatifs) | |
| ( | |
| echo @echo off | |
| echo setlocal | |
| echo set "ROOT=%%~dp0" | |
| echo set PYTHONNOUSERSITE=1 | |
| echo set PYTHONDONTWRITEBYTECODE=1 | |
| echo set "HOME=%%ROOT%%Data" | |
| echo set "USERPROFILE=%%ROOT%%Data" | |
| echo set "TIKTOKEN_CACHE_DIR=%%ROOT%%Data\tiktoken" | |
| echo "%%ROOT%%App\python\python.exe" "%%ROOT%%launch.py" %%* | |
| ) > "%ROOT%\litellm.cmd" | |
| :: config d'exemple (persistante, facon PortableApps) | |
| ( | |
| echo model_list: | |
| echo - model_name: exemple | |
| echo litellm_params: | |
| echo model: openai/mistral-large | |
| echo api_base: https://gateway.example.com/v1 | |
| echo api_key: os.environ/GATEWAY_API_KEY | |
| ) > "%ROOT%\Data\config.yaml" | |
| mkdir "%ROOT%\Data\tiktoken" | |
| echo [6/6] Smoke test... | |
| call "%ROOT%\litellm.cmd" --version | |
| if errorlevel 1 ( | |
| echo [ERREUR] le smoke test a echoue | |
| exit /b 1 | |
| ) | |
| echo. | |
| echo OK : package pret dans %ROOT% (Python %PYVER%) | |
| echo Usage : litellm.cmd --config Data\config.yaml --port 4000 | |
| endlocal |
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
| @echo off | |
| setlocal EnableExtensions | |
| :: ============================================================ | |
| :: prep_wheels.bat -- MACHINE ONLINE | |
| :: Telecharge les bonnes versions de Python et remplit C:\wheels : | |
| :: - Python complet (package NuGet, avec include\ et libs\) | |
| :: utilise pour construire les wheels -> aucun Python requis | |
| :: dans le PATH, et python312.lib present si compilation | |
| :: - Python embeddable (pour le package portable) | |
| :: - wheels de litellm[proxy], wheel de pip, get-pip.py | |
| :: Prerequis : curl uniquement. MSVC seulement si un paquet | |
| :: n'existe qu'en sdist. | |
| :: ============================================================ | |
| set "WHEELS=C:\wheels" | |
| set "PYVER=3.12.10" | |
| set "WORK=%TEMP%\litellm-build-python" | |
| :: PYTAG (ex: 312), derive de PYVER | |
| for /f "tokens=1,2 delims=." %%a in ("%PYVER%") do set "PYTAG=%%a%%b" | |
| if not exist "%WHEELS%" mkdir "%WHEELS%" | |
| echo [1/6] Telechargement du Python complet %PYVER% (NuGet)... | |
| curl -L -o "%TEMP%\python-full-%PYVER%.zip" "https://www.nuget.org/api/v2/package/python/%PYVER%" || exit /b 1 | |
| if exist "%WORK%" rmdir /s /q "%WORK%" | |
| powershell -NoProfile -Command "Expand-Archive -LiteralPath '%TEMP%\python-full-%PYVER%.zip' -DestinationPath '%WORK%'" | |
| if errorlevel 1 exit /b 1 | |
| set "PYFULL=%WORK%\tools\python.exe" | |
| :: controle : la version telechargee doit correspondre a PYVER | |
| "%PYFULL%" -c "import sys,platform; sys.exit(0 if platform.python_version()=='%PYVER%' else 1)" | |
| if errorlevel 1 ( | |
| echo [ERREUR] version Python inattendue dans le package NuGet | |
| exit /b 1 | |
| ) | |
| echo [2/6] Bootstrap de pip (ensurepip)... | |
| "%PYFULL%" -m ensurepip --default-pip || exit /b 1 | |
| "%PYFULL%" -m pip install --upgrade pip --quiet || exit /b 1 | |
| echo [3/6] Construction des wheels de litellm[proxy]... | |
| "%PYFULL%" -m pip wheel "litellm[proxy]" -w "%WHEELS%" || exit /b 1 | |
| echo [4/6] Telechargement du wheel de pip... | |
| "%PYFULL%" -m pip download pip -d "%WHEELS%" --only-binary=:all: || exit /b 1 | |
| echo [5/6] Telechargement de get-pip.py... | |
| curl -L -o "%WHEELS%\get-pip.py" https://bootstrap.pypa.io/get-pip.py || exit /b 1 | |
| echo [6/6] Telechargement du Python embeddable %PYVER%... | |
| curl -L -o "%WHEELS%\python-%PYVER%-embed-amd64.zip" "https://www.python.org/ftp/python/%PYVER%/python-%PYVER%-embed-amd64.zip" || exit /b 1 | |
| :: marqueur de version lu par build_litellm_portable.bat | |
| > "%WHEELS%\PYVER.txt" echo %PYVER% | |
| echo. | |
| echo OK : %WHEELS% est pret (Python %PYVER%, wheels cp%PYTAG%). | |
| endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment