-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.bat
More file actions
149 lines (130 loc) · 4.54 KB
/
install.bat
File metadata and controls
149 lines (130 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
@echo off
setlocal enabledelayedexpansion
REM PostForge Installation Script for Windows
REM Checks prerequisites and sets up the Python environment
echo ==================================
echo PostForge Installation Script
echo ==================================
echo.
REM Change to the directory where this script lives
cd /d "%~dp0"
REM Check Python version
echo Checking Python version...
where python >nul 2>&1
if %errorlevel% neq 0 (
echo Error: Python not found.
echo.
echo Please install Python 3.13+ from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation.
exit /b 1
)
for /f "tokens=*" %%i in ('python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYTHON_VERSION=%%i
for /f "tokens=*" %%i in ('python -c "import sys; print(sys.version_info.major)"') do set PYTHON_MAJOR=%%i
for /f "tokens=*" %%i in ('python -c "import sys; print(sys.version_info.minor)"') do set PYTHON_MINOR=%%i
echo Found Python %PYTHON_VERSION%
if %PYTHON_MAJOR% lss 3 (
echo Error: Python 3.12+ required ^(3.13+ recommended^).
echo Found Python %PYTHON_VERSION%
exit /b 1
)
if %PYTHON_MAJOR% equ 3 if %PYTHON_MINOR% lss 12 (
echo Error: Python 3.12+ required ^(3.13+ recommended^).
echo Found Python %PYTHON_VERSION%
exit /b 1
)
if %PYTHON_MAJOR% equ 3 if %PYTHON_MINOR% lss 13 (
echo Warning: Python 3.13+ recommended for best experience.
)
echo Python version OK
echo.
REM Create virtual environment
echo Setting up Python virtual environment...
if exist "venv\Scripts\python.exe" (
echo Virtual environment already exists.
) else (
if exist "venv" rmdir /s /q venv
python -m venv venv
if %errorlevel% neq 0 (
if exist "venv" rmdir /s /q venv
echo.
echo Failed to create virtual environment.
echo.
echo Reinstall Python from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation.
echo.
echo Then run install.bat again.
exit /b 1
)
echo Created virtual environment.
)
REM Install package with dependencies
echo.
echo Installing Python dependencies...
echo.
venv\Scripts\python -m pip install --upgrade pip -q
if %errorlevel% neq 0 (
echo Error: Failed to upgrade pip.
exit /b 1
)
venv\Scripts\python -m pip install -e ".[qt,dev,visual-test]"
if %errorlevel% neq 0 (
echo.
echo Error: Failed to install dependencies.
echo.
echo If pycairo failed, you may need to install the GTK3 runtime:
echo https://github.com/nickvdp/gtk3-windows-installer
echo.
echo Then run install.bat again.
exit /b 1
)
REM Build Cython accelerators (optional - PostForge runs without them)
echo.
echo Building Cython accelerators...
venv\Scripts\python setup_cython.py build_ext --inplace >nul 2>&1
if %errorlevel% neq 0 goto cython_failed
echo Cython build OK -- execution loop accelerated (15-40%% speedup)
goto cython_done
:cython_failed
echo Cython build failed -- PostForge will use the pure Python fallback.
echo To enable Cython acceleration, install Microsoft C++ Build Tools:
echo https://visualstudio.microsoft.com/visual-cpp-build-tools/
echo Select the "Desktop development with C++" workload during installation.
echo Then run install.bat again.
:cython_done
REM Add venv\Scripts to user PATH so pf works from anywhere
set "SCRIPTS_DIR=%~dp0venv\Scripts"
echo.
echo Installing system commands (pf, postforge)...
echo %PATH% | findstr /i /c:"%SCRIPTS_DIR%" >nul 2>&1
if !errorlevel! equ 0 (
echo Commands already in PATH.
) else (
set "USER_PATH="
for /f "usebackq tokens=2,*" %%A in (`reg query HKCU\Environment /v PATH 2^>nul`) do set "USER_PATH=%%B"
if defined USER_PATH (
setx PATH "!USER_PATH!;%SCRIPTS_DIR%" >nul 2>&1
) else (
setx PATH "%SCRIPTS_DIR%" >nul 2>&1
)
if !errorlevel! equ 0 (
echo Added to PATH: %SCRIPTS_DIR%
echo.
echo NOTE: Open a new terminal window for the 'pf' command to be available.
) else (
echo Could not update PATH automatically.
echo To use 'pf' from anywhere, add this directory to your PATH:
echo %SCRIPTS_DIR%
)
)
echo.
echo ==================================
echo Installation Complete!
echo ==================================
echo.
echo Run PostForge with:
echo.
echo pf # Interactive prompt
echo pf samples\tiger.ps # Render the classic tiger
echo pf -d png input.ps # Save to .\pf_output directory
echo.
endlocal