okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-021-iE' into f-021-int3616148bb

main
2.9 KiB65 linesraw
1@echo off
2rem Strata for Windows: the first run installs everything and starts the model; later runs just start it.
3rem Needs only an NVIDIA or AMD graphics driver. Python is installed for your user account if it is missing (no admin needed).
4setlocal
5rem Python reads and writes text as UTF-8, not in the Windows code page (cp1251, cp866, ...): a folder or user name with Cyrillic or other letters stays intact (#3202).
6set "PYTHONUTF8=1"
7title Strata
8cd /d "%~dp0"
9rem A bundled Python runtime (the python\ folder of the terminal archive) is used when it is there: nothing to find,
10rem install or download. SETUP.bat and UPDATE.bat run this file, so they use it too.
11if exist "python\python.exe" goto bundled
12if exist ".venv\Scripts\python.exe" goto run
13
14call :findpy
15if defined PY goto venv
16echo.
17echo  Python 3.10 or newer is not installed. Installing Python 3.12 for your user account ...
18where winget >nul 2>nul
19if errorlevel 1 goto pyorg
20winget install -e --id Python.Python.3.12 --scope user --silent --source winget --accept-package-agreements --accept-source-agreements --disable-interactivity
21call :findpy
22if defined PY goto venv
23:pyorg
24echo  Downloading the Python installer from python.org ...
25powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol='Tls12'; Invoke-WebRequest -UseBasicParsing https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe -OutFile \"$env:TEMP\strata-python-setup.exe\""
26if exist "%TEMP%\strata-python-setup.exe" "%TEMP%\strata-python-setup.exe" /quiet InstallAllUsers=0 PrependPath=1 Include_launcher=1 Include_test=0
27call :findpy
28if defined PY goto venv
29echo.
30echo  Python could not be installed automatically.
31echo  Install 64-bit Python 3.12 from https://www.python.org/downloads/ ("Add python.exe to PATH"),
32echo  then double-click START-HERE.bat again.
33pause
34exit /b 1
35
36:venv
37rem a private environment inside this folder, so nothing is installed into the system Python
38%PY% -m venv .venv
39if exist ".venv\Scripts\python.exe" goto run
40echo  Could not create the Python environment in .venv
41pause
42exit /b 1
43
44:bundled
45set "PYTHONNOUSERSITE=1"
46set "PYTHONHOME="
47set "PYTHONPATH="
48"python\python.exe" setup.py %*
49if errorlevel 1 pause
50exit /b
51
52:run
53".venv\Scripts\python.exe" setup.py %*
54if errorlevel 1 pause
55exit /b
56
57:findpy
58rem the py launcher first, then python on PATH (not the Microsoft Store stub), then the usual per-user folders
59set "PY="
60py -3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) and sys.maxsize > 2**32 else 1)" >nul 2>nul
61if not errorlevel 1 set "PY=py -3" & goto :eof
62python -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) and sys.maxsize > 2**32 else 1)" >nul 2>nul
63if not errorlevel 1 set "PY=python" & goto :eof
64for %%V in (313 312 311 310) do if exist "%LOCALAPPDATA%\Programs\Python\Python%%V\python.exe" set "PY="%LOCALAPPDATA%\Programs\Python\Python%%V\python.exe"" & goto :eof
65goto :eof