Skip to content

Commit c8c324b

Browse files
committed
python installer
1 parent 4088bbc commit c8c324b

3 files changed

Lines changed: 55 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ __pycache__/
77
.tmp_spawningtool/
88
drop-log.txt
99
install-log.txt
10+
python-3.12.10-amd64.exe
1011
*.egg-info/
1112
dist/
1213
build/

Install once.bat

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,36 @@
22
setlocal
33
set "ROOT=%~dp0"
44
set "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

68
echo Setting up sc2-replay-salt...
79
echo Setup log for sc2-replay-salt>"%LOG%"
810
echo.>>"%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+
)
1735
if 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.
3452
pause
3553
exit /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
3885
echo.
3986
echo 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.
4188
echo.
4289
pause
4390
exit /b 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Decode StarCraft II replay files and print a readable build order for a selected
66

77
For a normal Windows workflow:
88

9-
1. Double-click `Install once.bat`.
9+
1. Double-click `Install once.bat`. If Python is missing, it downloads and installs Python 3.12 from python.org first.
1010
2. Drag one or more `.SC2Replay` files onto `Drop replays here.bat`.
1111
3. Open the `build order.txt` file created next to each replay.
1212

0 commit comments

Comments
 (0)