-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_dist_windows.cmd
214 lines (179 loc) · 7.44 KB
/
make_dist_windows.cmd
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
@echo off
setlocal EnableDelayedExpansion
cd /d %~dp0
:: config
set APP_NAME=MediaPlayer
set APP_ICON=app.ico
set DIR=%CD%
set APP_DIR=%CD%\dist\%APP_NAME%\
:: cleanup
rmdir /s /q "dist\%APP_NAME%" 2>nul
del "dist\%APP_NAME%-x64-setup.exe" 2>nul
del "dist\%APP_NAME%-x64-portable.7z" 2>nul
echo.
echo ****************************************
echo Checking requirements...
echo ****************************************
pip install -r requirements_windows.txt
pip install -r requirements_dist.txt
echo.
echo ****************************************
echo Running pyinstaller...
echo ****************************************
:: pyinstaller --noupx -w -i "%APP_ICON%" -n "%APP_NAME%" --version-file=version_res.txt --hidden-import videowidget -D main.py
pyinstaller %APP_NAME%_win.spec
echo.
echo ****************************************
echo Copying resources...
echo ****************************************
mkdir "dist\%APP_NAME%\_internal\resources"
copy resources\main.ui "dist\%APP_NAME%\_internal\resources\"
copy resources\main.rcc "dist\%APP_NAME%\_internal\resources\"
copy resources\style.css "dist\%APP_NAME%\_internal\resources\"
copy resources\mediainfos.ui "dist\%APP_NAME%\_internal\resources\"
copy resources\mediainfo.exe "dist\%APP_NAME%\_internal\resources\"
xcopy /e resources\filters "dist\%APP_NAME%\_internal\resources\filters\"
echo.
echo ****************************************
echo Optimizing application...
echo ****************************************
del "dist\%APP_NAME%\_internal\libssl-3.dll"
del "dist\%APP_NAME%\_internal\unicodedata.pyd"
del "dist\%APP_NAME%\_internal\_bz2.pyd"
del "dist\%APP_NAME%\_internal\_decimal.pyd"
del "dist\%APP_NAME%\_internal\_elementtree.pyd"
del "dist\%APP_NAME%\_internal\_hashlib.pyd"
del "dist\%APP_NAME%\_internal\_lzma.pyd"
del "dist\%APP_NAME%\_internal\_ssl.pyd"
del "dist\%APP_NAME%\_internal\_wmi.pyd"
del "dist\%APP_NAME%\_internal\api-ms-win-core-console-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-datetime-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-debug-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-errorhandling-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-file-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-file-l1-2-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-file-l2-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-handle-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-heap-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-interlocked-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-libraryloader-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-localization-l1-2-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-memory-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-namedpipe-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-processenvironment-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-processthreads-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-processthreads-l1-1-1.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-profile-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-rtlsupport-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-string-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-synch-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-synch-l1-2-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-sysinfo-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-timezone-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-util-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-conio-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-convert-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-environment-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-filesystem-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-heap-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-locale-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-math-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-process-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-runtime-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-stdio-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-string-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-time-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-crt-utility-l1-1-0.dll"
del "dist\%APP_NAME%\_internal\api-ms-win-core-fibers-l1-1-0.dll
del "dist\%APP_NAME%\_internal\libcrypto-3.dll"
del "dist\%APP_NAME%\_internal\ucrtbase.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\d3dcompiler_47.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\libEGL.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\libGLESv2.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\opengl32sw.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5DBus.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5Network.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5Qml.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5QmlModels.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5Quick.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5Svg.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\bin\Qt5WebSockets.dll"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\uic"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\Qt5\translations"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\generic"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\iconengines"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\imageformats"
rmdir /s /q "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\platformthemes"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\platforms\qminimal.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\platforms\qoffscreen.dll"
del "dist\%APP_NAME%\_internal\PyQt5\Qt5\plugins\platforms\qwebgl.dll"
call :create_7z
call :create_installer
:done
echo.
echo ****************************************
echo Done.
echo ****************************************
echo.
pause
endlocal
goto :eof
:create_7z
if not exist "C:\Program Files\7-Zip\" (
echo.
echo ****************************************
echo 7z.exe not found at default location, omitting .7z creation...
echo ****************************************
exit /B
)
echo.
echo ****************************************
echo Creating .7z archive...
echo ****************************************
cd dist
set PATH=C:\Program Files\7-Zip;%PATH%
7z a "%APP_NAME%-x64-portable.7z" "%APP_NAME%\*"
cd ..
exit /B
:create_installer
if not exist "C:\Program Files (x86)\NSIS\" (
echo.
echo ****************************************
echo NSIS not found at default location, omitting installer creation...
echo ****************************************
exit /B
)
echo.
echo ****************************************
echo Creating installer...
echo ****************************************
:: get length of APP_DIR
set TF=%TMP%\x
echo %APP_DIR%> %TF%
for %%? in (%TF%) do set /a LEN=%%~z? - 2
del %TF%
call :make_abs_nsh nsis\uninstall_list.nsh
del "%NSH%" 2>nul
cd "%APP_DIR%"
for /F %%f in ('dir /b /a-d') do (
echo Delete "$INSTDIR\%%f" >> "%NSH%"
)
for /F %%d in ('dir /s /b /aD') do (
cd "%%d"
set DIR_REL=%%d
for /F %%f IN ('dir /b /a-d 2^>nul') do (
echo Delete "$INSTDIR\!DIR_REL:~%LEN%!\%%f" >> "%NSH%"
)
)
cd "%APP_DIR%"
for /F %%d in ('dir /s /b /ad^|sort /r') do (
set DIR_REL=%%d
echo RMDir "$INSTDIR\!DIR_REL:~%LEN%!" >> "%NSH%"
)
cd "%DIR%"
set PATH=C:\Program Files (x86)\NSIS;%PATH%
makensis nsis\make-installer.nsi
exit /B
:make_abs_nsh
set NSH=%~dpnx1%
exit /B