-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.bat
42 lines (36 loc) · 1.54 KB
/
build.bat
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
@echo off
cd ..\client
REM Create a temporary Python script to discover usable PyQt modules.
set "temp_dir=%TEMP%\NSO-RPC\temp"
mkdir "%temp_dir%"
set "temp_script=%temp_dir%\temp.py"
echo import sys > "%temp_script%"
echo PYQT_PACKAGE = '' >> "%temp_script%"
echo try: >> "%temp_script%"
echo from PyQt6.QtWidgets import QApplication >> "%temp_script%"
echo PYQT_PACKAGE = 'PyQt6' >> "%temp_script%"
echo except ImportError: >> "%temp_script%"
echo try: >> "%temp_script%"
echo from PyQt5.QtWidgets import QApplication >> "%temp_script%"
echo PYQT_PACKAGE = 'PyQt5' >> "%temp_script%"
echo except ImportError: >> "%temp_script%"
echo print('PyQt6 or PyQt5 is required. Please install either of them.', file=sys.stderr) >> "%temp_script%"
echo sys.exit(1) >> "%temp_script%"
echo print(PYQT_PACKAGE) >> "%temp_script%"
for /f "usebackq tokens=*" %%G in (`python "%temp_script%"`) do (
set "PYQT_PACKAGE=%%G"
)
rmdir /s /q "%temp_dir%"
REM Check if PyQt package is set
if "%PYQT_PACKAGE%"=="" (
exit /b 1
)
echo Building with %PYQT_PACKAGE%
REM Install requirements
python -m pip install -r ../client/requirements.txt GitPython pypiwin32 winshell pyinstaller>=5.12 pyinstaller-hooks-contrib==2023.4
REM Generate version.txt
python _version.py
REM Build the executable using PyInstaller
python -m PyInstaller --onefile --clean --noconsole --exclude-module autopep8 --noupx --add-data "*.png;." --add-data "version.txt;." --icon=icon.ico --name=NSO-RPC ..\client\app.py
REM Open the 'dist' directory
start .\dist