22setlocal
33set " ROOT = %~dp0 "
44set " LOG = %ROOT% install-log.txt"
5+ set " PYTHON_URL = https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe"
6+ set " PYTHON_INSTALLER = %ROOT% python-3.12.10-amd64.exe"
57
68echo Setting up sc2-replay-salt...
79echo Setup log for sc2-replay-salt> " %LOG% "
810echo .>> " %LOG% "
911
10- where py > nul 2 > nul
11- if %ERRORLEVEL% == 0 (
12- set " PY = py -3"
13- ) else (
14- set " PY = python"
12+ set " PY = "
13+ if exist " %ROOT% .venv\Scripts\python.exe" (
14+ set " PY = %ROOT% .venv\Scripts\python.exe"
15+ )
16+
17+ if not defined PY (
18+ where py > nul 2 > nul
19+ if not errorlevel 1 (
20+ set " PY = py -3"
21+ )
22+ )
23+
24+ if not defined PY (
25+ where python > nul 2 > nul
26+ if not errorlevel 1 (
27+ set " PY = python"
28+ )
1529)
1630
31+ if not defined PY (
32+ call :install_python
33+ if errorlevel 1 goto failed
34+ )
1735if not exist " %ROOT% .venv\Scripts\python.exe" (
1836 echo Creating the private Python environment...
1937 %PY% -m venv " %ROOT% .venv" >> " %LOG% " 2 >> & 1
@@ -34,10 +52,39 @@ echo.
3452pause
3553exit /b 0
3654
55+ :install_python
56+ echo Python was not found. Installing Python 3.12...
57+ echo Python was not found. Downloading %PYTHON_URL% >> " %LOG% "
58+ " %SystemRoot% \System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command " [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%PYTHON_URL% ' -OutFile '%PYTHON_INSTALLER% '" >> " %LOG% " 2 >> & 1
59+ if errorlevel 1 exit /b 1
60+
61+ echo Running the Python installer...>> " %LOG% "
62+ " %PYTHON_INSTALLER% " /quiet InstallAllUsers=0 PrependPath=1 Include_launcher=1 Include_pip=1 Include_test=0 SimpleInstall=1 >> " %LOG% " 2 >> & 1
63+ if errorlevel 1 exit /b 1
64+
65+ if exist " %LocalAppData% \Programs\Python\Python312\python.exe" (
66+ set " PY = %LocalAppData% \Programs\Python\Python312\python.exe"
67+ exit /b 0
68+ )
69+
70+ where py > nul 2 > nul
71+ if not errorlevel 1 (
72+ set " PY = py -3.12"
73+ exit /b 0
74+ )
75+
76+ where python > nul 2 > nul
77+ if not errorlevel 1 (
78+ set " PY = python"
79+ exit /b 0
80+ )
81+
82+ exit /b 1
83+
3784:failed
3885echo .
3986echo Setup failed, but the details were saved to install-log.txt.
40- echo Make sure Python 3.10 or newer is installed, then run this file again .
87+ echo Close this window and run " Install once.bat " again. If it still fails, send install-log.txt .
4188echo .
4289pause
4390exit /b 1
0 commit comments