-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_windows.bat
More file actions
243 lines (207 loc) · 7.91 KB
/
Copy pathbuild_windows.bat
File metadata and controls
243 lines (207 loc) · 7.91 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
@echo off
REM build_windows.bat — Genera el instalador y el portable de Windows
REM
REM Requisitos previos:
REM - Python 3.10+ instalado y en PATH
REM - pip install -r requirements.txt ejecutado
REM - Inno Setup 6 instalado en la ruta por defecto (para el instalador)
REM
REM Que hace este script:
REM 1. Verifica Python y dependencias
REM 2. Verifica PySide6 (la app de escritorio es Qt nativo, sin pywebview)
REM 3. Construye el bundle con PyInstaller
REM 4. Empaqueta el ZIP portable
REM 5. Compila el instalador con Inno Setup
REM
REM Uso:
REM build_windows.bat
REM build_windows.bat --skip-pyinstaller (bundle ya existe)
REM build_windows.bat --skip-inno (solo bundle + ZIP, sin instalador)
setlocal enabledelayedexpansion
REM ---------------------------------------------------------------------------
REM CONFIGURACION
REM ---------------------------------------------------------------------------
set PYTHON=python
set PIP=pip
set APP_NAME=PythonDSProgram
set VERSION=3.11.0
set SPEC_FILE=program.spec
set INNO_SETUP="C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
set INNO_SCRIPT=installer\setup.iss
set OUTPUT_DIR=dist_installer
set PORTABLE_DIR=release_artifacts
set SKIP_PYINSTALLER=0
set SKIP_INNO=0
for %%A in (%*) do (
if "%%A"=="--skip-pyinstaller" set SKIP_PYINSTALLER=1
if "%%A"=="--skip-inno" set SKIP_INNO=1
)
REM ---------------------------------------------------------------------------
REM BANNER
REM ---------------------------------------------------------------------------
echo.
echo ============================================================
echo PYTHON DS PROGRAM ^| BUILD WINDOWS v%VERSION%
echo ============================================================
echo.
REM ---------------------------------------------------------------------------
REM PASO 1: VERIFICAR PYTHON
REM ---------------------------------------------------------------------------
echo [1/6] Verificando Python...
%PYTHON% --version >nul 2>&1
if errorlevel 1 (
echo ERROR: Python no encontrado en PATH.
echo Descarga Python 3.10+ desde https://python.org/downloads/
echo Marca "Add Python to PATH" durante la instalacion.
exit /b 1
)
for /f "tokens=*" %%v in ('%PYTHON% --version') do set PYTHON_VER=%%v
echo OK: !PYTHON_VER!
REM ---------------------------------------------------------------------------
REM PASO 2: VERIFICAR / INSTALAR DEPENDENCIAS
REM ---------------------------------------------------------------------------
echo.
echo [2/6] Verificando dependencias de la app...
%PYTHON% -c "import flask, pandas, sklearn, matplotlib, nbformat" >nul 2>&1
if errorlevel 1 (
echo Instalando requirements.txt...
%PIP% install -r requirements.txt
if errorlevel 1 (
echo ERROR: No se pudieron instalar las dependencias.
exit /b 1
)
)
echo OK: flask, pandas, scikit-learn, matplotlib, nbformat
REM ---------------------------------------------------------------------------
REM PASO 3: VERIFICAR / INSTALAR PYSIDE6 (Qt nativo, reemplaza a pywebview)
REM ---------------------------------------------------------------------------
echo.
echo [3/6] Verificando PySide6 (app Qt nativa, sin WebView)...
%PYTHON% -c "import PySide6" >nul 2>&1
if errorlevel 1 (
echo Instalando PySide6...
%PIP% install "PySide6>=6.6"
if errorlevel 1 (
echo ERROR: No se pudo instalar PySide6.
echo Intenta manualmente: pip install "PySide6>=6.6"
exit /b 1
)
)
for /f "tokens=*" %%v in ('%PYTHON% -c "import PySide6; print(PySide6.__version__)"') do set WV_VER=%%v
echo OK: PySide6 !WV_VER!
REM ---------------------------------------------------------------------------
REM PASO 4: VERIFICAR / INSTALAR PYINSTALLER
REM ---------------------------------------------------------------------------
echo.
echo [4/6] Verificando PyInstaller...
%PYTHON% -m PyInstaller --version >nul 2>&1
if errorlevel 1 (
echo Instalando PyInstaller...
%PIP% install pyinstaller
if errorlevel 1 (
echo ERROR: No se pudo instalar PyInstaller.
exit /b 1
)
)
for /f "tokens=*" %%v in ('%PYTHON% -m PyInstaller --version') do set PYIN_VER=%%v
echo OK: PyInstaller !PYIN_VER!
REM ---------------------------------------------------------------------------
REM PASO 5: PYINSTALLER — GENERAR EL BUNDLE
REM ---------------------------------------------------------------------------
echo.
if "%SKIP_PYINSTALLER%"=="1" (
echo [5/6] PyInstaller: OMITIDO --skip-pyinstaller
if not exist "dist\%APP_NAME%\%APP_NAME%.exe" (
echo ERROR: dist\%APP_NAME%\%APP_NAME%.exe no existe. Regeneralo sin --skip-pyinstaller.
exit /b 1
)
) else (
echo [5/6] Construyendo bundle con PyInstaller...
echo Spec: %SPEC_FILE%
echo Esto puede tardar varios minutos la primera vez...
echo.
if exist "build\%APP_NAME%" (
echo Limpiando build anterior...
rmdir /s /q "build\%APP_NAME%"
)
%PYTHON% -m PyInstaller %SPEC_FILE% --noconfirm --log-level WARN
if errorlevel 1 (
echo.
echo ERROR: PyInstaller fallo. Ejecuta con --log-level DEBUG para mas detalle.
exit /b 1
)
echo.
echo Bundle generado en: dist\%APP_NAME%\
)
if not exist "dist\%APP_NAME%\%APP_NAME%.exe" (
echo ERROR: El ejecutable no fue generado.
exit /b 1
)
echo OK: dist\%APP_NAME%\%APP_NAME%.exe
REM ---------------------------------------------------------------------------
REM EMPAQUETAR PORTABLE (ZIP)
REM ---------------------------------------------------------------------------
echo.
echo Empaquetando version portable...
if not exist "%PORTABLE_DIR%" mkdir "%PORTABLE_DIR%"
set PORTABLE_ZIP=%PORTABLE_DIR%\%APP_NAME%_windows_portable_v%VERSION%.zip
REM Eliminar zip anterior si existe
if exist "%PORTABLE_ZIP%" del /f /q "%PORTABLE_ZIP%"
REM Usar PowerShell para comprimir (disponible en Win10+)
powershell -NoProfile -Command ^
"Compress-Archive -Path 'dist\%APP_NAME%\*' -DestinationPath '%PORTABLE_ZIP%' -Force"
if errorlevel 1 (
echo ADVERTENCIA: No se pudo crear el ZIP portable.
echo Puedes comprimir manualmente la carpeta dist\%APP_NAME%\
) else (
echo OK: %PORTABLE_ZIP%
)
REM ---------------------------------------------------------------------------
REM PASO 6: INNO SETUP — GENERAR EL INSTALADOR
REM ---------------------------------------------------------------------------
echo.
if "%SKIP_INNO%"=="1" (
echo [6/6] Inno Setup: OMITIDO --skip-inno
goto :done
)
echo [6/6] Compilando instalador con Inno Setup...
if not exist %INNO_SETUP% (
echo.
echo ADVERTENCIA: Inno Setup no encontrado en %INNO_SETUP%
echo Opciones:
echo A) Instalar Inno Setup 6 desde https://jrsoftware.org/isinfo.php
echo B) Ajustar la variable INNO_SETUP en este script
echo C) Ejecutar con --skip-inno para solo bundle + ZIP portable
echo.
goto :done
)
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
%INNO_SETUP% "%INNO_SCRIPT%"
if errorlevel 1 (
echo ERROR: Inno Setup fallo. Revisa installer\setup.iss.
exit /b 1
)
echo OK: %OUTPUT_DIR%\%APP_NAME%_Setup_v%VERSION%.exe
REM ---------------------------------------------------------------------------
REM RESUMEN FINAL
REM ---------------------------------------------------------------------------
:done
echo.
echo ============================================================
echo BUILD COMPLETADO
echo ============================================================
echo.
echo Portable (descomprimir y ejecutar PythonDSProgram.exe):
echo %PORTABLE_ZIP%
echo.
if exist "%OUTPUT_DIR%\%APP_NAME%_Setup_v%VERSION%.exe" (
echo Instalador (doble clic para instalar):
echo %OUTPUT_DIR%\%APP_NAME%_Setup_v%VERSION%.exe
echo.
)
echo NOTA: El ejecutable abre una ventana de escritorio Qt nativa (PySide6).
echo No se abre ningun navegador. No levanta servidor HTTP. No usa WebView.
echo.
echo ============================================================
endlocal
exit /b 0