| 1 |
@echo off |
| 2 |
REM This script adapted from PythonQwt project |
| 3 |
REM ====================================================== |
| 4 |
REM Executable build script |
| 5 |
REM ====================================================== |
| 6 |
REM Licensed under the terms of the MIT License |
| 7 |
REM Copyright (c) 2020-2023 Pierre Raybaut |
| 8 |
REM (see PythonQwt LICENSE file for more details) |
| 9 |
REM ====================================================== |
| 10 |
call %~dp0utils GetScriptPath SCRIPTPATH |
| 11 |
call %FUNC% GetLibName LIBNAME |
| 12 |
call %FUNC% SetPythonPath |
| 13 |
call %FUNC% UsePython |
| 14 |
call %FUNC% GetVersion VERSION |
| 15 |
set REPODIR=%SCRIPTPATH%\.. |
| 16 |
|
| 17 |
@REM Keep this around for Qt hooks debugging (the output must not be empty): |
| 18 |
@REM %PYTHON% -c "from PyInstaller.utils.hooks import qt; print(qt.pyqt5_library_info.location)" |
| 19 |
|
| 20 |
@REM Clone repository in a temporary directory |
| 21 |
set CLONEDIR=%REPODIR%\..\%LIBNAME%-tempdir |
| 22 |
if exist %CLONEDIR% ( rmdir /s /q %CLONEDIR% ) |
| 23 |
git clone -l -s . %CLONEDIR% |
| 24 |
|
| 25 |
@REM Compile translations in cloned directory using dev environment (which has babel) |
| 26 |
@REM This must happen BEFORE pushd because run_with_env.py loads .env from current dir |
| 27 |
%PYTHON% scripts/run_with_env.py %PYTHON% -m guidata.utils.translations compile --name datalab --directory %CLONEDIR% |
| 28 |
|
| 29 |
pushd %CLONEDIR% |
| 30 |
|
| 31 |
@REM Backup PYTHONPATH |
| 32 |
set OLD_PYTHONPATH=%PYTHONPATH% |
| 33 |
@REM Make a new virtual environment for building the executable |
| 34 |
set VENV_DIR=%REPODIR%\..\%LIBNAME%-temp-venv |
| 35 |
if exist %VENV_DIR% ( rmdir /s /q %VENV_DIR% ) |
| 36 |
%PYTHON% -m venv %VENV_DIR% |
| 37 |
set PYTHON=%VENV_DIR%\Scripts\python.exe |
| 38 |
set PYTHONPATH=%CLONEDIR% |
| 39 |
@REM Install required packages in the virtual environment |
| 40 |
%PYTHON% -m pip install --upgrade pip setuptools wheel |
| 41 |
@REM Install DataLab and its dependencies |
| 42 |
%PYTHON% -m pip install .[exe] |
| 43 |
|
| 44 |
@REM Generating icon |
| 45 |
set INKSCAPE_PATH="C:\Program Files\Inkscape\bin\inkscape.exe" |
| 46 |
set RESPATH=%CLONEDIR%\resources |
| 47 |
for %%s in (16 24 32 48 128 256) do ( |
| 48 |
%INKSCAPE_PATH% "%RESPATH%\DataLab.svg" -o "%RESPATH%\tmp-%%s.png" -w %%s -h %%s |
| 49 |
) |
| 50 |
magick "%RESPATH%\tmp-*.png" "%RESPATH%\DataLab.ico" |
| 51 |
del "%RESPATH%\tmp-*.png" |
| 52 |
|
| 53 |
@REM Note: Translations were already compiled in the cloned directory using the dev environment |
| 54 |
|
| 55 |
@REM Generate build manifest |
| 56 |
%PYTHON% scripts\generate_manifest.py |
| 57 |
|
| 58 |
@REM Building executable |
| 59 |
%PYTHON% -m PyInstaller DataLab.spec --noconfirm --clean |
| 60 |
|
| 61 |
@REM Copy manifest to executable root directory |
| 62 |
copy "manifest.json" "dist\DataLab\manifest.json" /Y |
| 63 |
|
| 64 |
@REM Windows 7 SP1 compatibility fix |
| 65 |
copy "%RESPATH%\api-ms-win-core-path-l1-1-0.dll" "dist\DataLab\_internal" /Y |
| 66 |
|
| 67 |
@REM Zipping executable |
| 68 |
cd dist |
| 69 |
set ZIPNAME=DataLab-v%VERSION%_exe.zip |
| 70 |
"C:\Program Files\7-Zip\7z.exe" a -mx1 "%ZIPNAME%" DataLab |
| 71 |
popd |
| 72 |
|
| 73 |
if not exist %REPODIR%\dist ( mkdir %REPODIR%\dist ) |
| 74 |
@REM Move zipped executable to dist directory |
| 75 |
move %CLONEDIR%\dist\%ZIPNAME% %REPODIR%\dist |
| 76 |
@REM Move generated folder to dist directory |
| 77 |
move %CLONEDIR%\dist\DataLab %REPODIR%\dist |
| 78 |
|
| 79 |
@REM Cleanup temporary directories |
| 80 |
rmdir /s /q %CLONEDIR% |
| 81 |
rmdir /s /q %VENV_DIR% |
| 82 |
@REM Restore PYTHONPATH |
| 83 |
set PYTHONPATH=%OLD_PYTHONPATH% |
| 84 |
|
| 85 |
call %FUNC% EndOfScript |