Improve WINDOWS_INSTALL.bat to support version selection and install dependencies using uv

This commit is contained in:
Deniz Şafak
2025-12-13 20:27:48 +03:00
parent c3673b6dc7
commit 5735f05be0
+54 -19
View File
@@ -20,6 +20,7 @@ set MISAKI_LANG=en
for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do @echo(%%A for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do @echo(%%A
set CURRENT_DIR="%CD%" set CURRENT_DIR="%CD%"
set "UV_CACHE_DIR=%~dp0.uv_cache"
set NAME=abogen set NAME=abogen
set PROJECTFOLDER=abogen set PROJECTFOLDER=abogen
set RUN=python_embedded\Scripts\abogen.exe set RUN=python_embedded\Scripts\abogen.exe
@@ -29,6 +30,28 @@ set refrenv=%PROJECTFOLDER%\refrenv.bat
set PYTHON_PATH=python_embedded\pythonw.exe set PYTHON_PATH=python_embedded\pythonw.exe
set PYTHON_CONSOLE_PATH=python_embedded\python.exe set PYTHON_CONSOLE_PATH=python_embedded\python.exe
:: ---------------------------------------------------------
:: Version Selection
:: ---------------------------------------------------------
echo.
echo Select installation version:
echo [1] Stable (PyPI) - Safer, recommended for most users.
echo [2] Dev (Local) - Install from current folder (may include commits after the latest release).
echo.
choice /C 12 /M "Your choice"
if errorlevel 2 (
set INSTALL_SOURCE=dev
echo.
echo Selected: Dev - Local Editable
) else (
set INSTALL_SOURCE=pypi
echo.
echo Selected: Stable - PyPI
)
echo.
:: ---------------------------------------------------------
:: Check for updates :: Check for updates
echo Checking for updates... echo Checking for updates...
set VERSION_FILE=%PROJECTFOLDER%\VERSION set VERSION_FILE=%PROJECTFOLDER%\VERSION
@@ -197,18 +220,19 @@ if not "%~1"=="" (
echo Open with: "%~1" echo Open with: "%~1"
) )
:: Update pip :: Update pip and install uv
echo Updating pip... echo Updating pip and installing uv...
%PYTHON_CONSOLE_PATH% -m pip install --upgrade pip --no-warn-script-location %PYTHON_CONSOLE_PATH% -m pip install --upgrade pip --no-warn-script-location
%PYTHON_CONSOLE_PATH% -m pip install uv --no-warn-script-location
if errorlevel 1 ( if errorlevel 1 (
echo Failed to update pip. echo Failed to install uv.
pause pause
exit /b exit /b
) )
:: Install docopt's fixed version :: Install docopt's fixed version
echo Installing fixed version of docopt... echo Installing fixed version of docopt...
%PYTHON_CONSOLE_PATH% -m pip install --force-reinstall https://github.com/denizsafak/abogen/raw/refs/heads/main/abogen/resources/docopt-0.6.2-py2.py3-none-any.whl --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system --force-reinstall https://github.com/denizsafak/abogen/raw/refs/heads/main/abogen/resources/docopt-0.6.2-py2.py3-none-any.whl
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install fixed version of docopt. echo Failed to install fixed version of docopt.
pause pause
@@ -217,7 +241,7 @@ if errorlevel 1 (
:: Install progress's fixed version :: Install progress's fixed version
echo Installing fixed version of progress... echo Installing fixed version of progress...
%PYTHON_CONSOLE_PATH% -m pip install --force-reinstall https://github.com/denizsafak/abogen/raw/refs/heads/main/abogen/resources/progress-1.6-py3-none-any.whl --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system --force-reinstall https://github.com/denizsafak/abogen/raw/refs/heads/main/abogen/resources/progress-1.6-py3-none-any.whl
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install fixed version of progress. echo Failed to install fixed version of progress.
pause pause
@@ -226,7 +250,7 @@ if errorlevel 1 (
:: Install setup requirements :: Install setup requirements
echo Installing setup requirements... echo Installing setup requirements...
%PYTHON_CONSOLE_PATH% -m pip install --upgrade setuptools setuptools-scm wheel sphinx hatchling editables --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system --upgrade setuptools setuptools-scm wheel sphinx hatchling editables
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install setup requirements. echo Failed to install setup requirements.
pause pause
@@ -235,32 +259,43 @@ if errorlevel 1 (
:: Install gpustat :: Install gpustat
echo Installing gpustat... echo Installing gpustat...
%PYTHON_CONSOLE_PATH% -m pip install gpustat --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system gpustat
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install gpustat. echo Failed to install gpustat.
pause pause
exit /b exit /b
) )
:: Install project and dependencies from pyproject.toml :: Install project based on user selection
echo Checking and installing project dependencies... if "%INSTALL_SOURCE%"=="pypi" (
if exist %PYPROJECT_FILE% ( echo Installing stable version from PyPI...
echo Installing project from pyproject.toml... %PYTHON_CONSOLE_PATH% -m uv pip install --system abogen
%PYTHON_CONSOLE_PATH% -m pip install -e . --no-warn-script-location
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install from pyproject.toml. echo Failed to install abogen from PyPI.
pause pause
exit /b exit /b
) )
) else ( ) else (
echo Warning: pyproject.toml not found in current directory. echo Checking and installing project dependencies...
pause if exist %PYPROJECT_FILE% (
echo Installing project from pyproject.toml using uv...
:: Using uv pip install --system --editable
%PYTHON_CONSOLE_PATH% -m uv pip install --system --editable .
if errorlevel 1 (
echo Failed to install from pyproject.toml.
pause
exit /b
)
) else (
echo Warning: pyproject.toml not found in current directory.
pause
)
) )
:: Install misaki again if MISAKI_LANG is not set to "en" :: Install misaki again if MISAKI_LANG is not set to "en" via uv
if "%MISAKI_LANG%" NEQ "en" ( if "%MISAKI_LANG%" NEQ "en" (
echo Configuring language pack: %MISAKI_LANG% echo Configuring language pack: %MISAKI_LANG%
%PYTHON_CONSOLE_PATH% -m pip install misaki[%MISAKI_LANG%] --upgrade --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system misaki[%MISAKI_LANG%] --upgrade
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install misaki language pack. echo Failed to install misaki language pack.
pause pause
@@ -281,7 +316,7 @@ if /I "%IS_NVIDIA%"=="true" (
echo "Installing PyTorch with CUDA (12.8) support..." echo "Installing PyTorch with CUDA (12.8) support..."
:: We need to use an older version of PyTorch (2.8.0) until this issue is fixed: https://github.com/pytorch/pytorch/issues/166628 :: We need to use an older version of PyTorch (2.8.0) until this issue is fixed: https://github.com/pytorch/pytorch/issues/166628
:: Solution mentioned by @mazenemam19 in #99: :: Solution mentioned by @mazenemam19 in #99:
%PYTHON_CONSOLE_PATH% -m pip install torch==2.8.0+cu128 torchvision==0.23.0+cu128 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system torch==2.8.0+cu128 torchvision==0.23.0+cu128 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128
echo. echo.
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install PyTorch. echo Failed to install PyTorch.
@@ -307,7 +342,7 @@ if /I "%IS_NVIDIA%"=="true" (
echo "Installing PyTorch with CUDA (12.8) support..." echo "Installing PyTorch with CUDA (12.8) support..."
:: We need to use an older version of PyTorch (2.8.0) until this issue is fixed: https://github.com/pytorch/pytorch/issues/166628 :: We need to use an older version of PyTorch (2.8.0) until this issue is fixed: https://github.com/pytorch/pytorch/issues/166628
:: Solution mentioned by @mazenemam19 in #99: :: Solution mentioned by @mazenemam19 in #99:
%PYTHON_CONSOLE_PATH% -m pip install torch==2.8.0+cu128 torchvision==0.23.0+cu128 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location %PYTHON_CONSOLE_PATH% -m uv pip install --system torch==2.8.0+cu128 torchvision==0.23.0+cu128 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install PyTorch. echo Failed to install PyTorch.
pause pause