Skip to content

Commit e3b6796

Browse files
committed
Refactor executable build script: create virtual environment and install dependencies for executable build
1 parent 6e7f0f1 commit e3b6796

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

scripts/build_exe.bat

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ if exist %CLONEDIR% ( rmdir /s /q %CLONEDIR% )
2323
git clone -l -s . %CLONEDIR%
2424
pushd %CLONEDIR%
2525

26+
@REM Backup PYTHONPATH
27+
set OLD_PYTHONPATH=%PYTHONPATH%
28+
@REM Make a new virtual environment for building the executable
29+
set VENV_DIR=%REPODIR%\..\%LIBNAME%-temp-venv
30+
if exist %VENV_DIR% ( rmdir /s /q %VENV_DIR% )
31+
%PYTHON% -m venv %VENV_DIR%
32+
set PYTHON=%VENV_DIR%\Scripts\python.exe
33+
set PYTHONPATH=%CLONEDIR%
34+
@REM Install required packages in the virtual environment
35+
%PYTHON% -m pip install --upgrade pip setuptools wheel
36+
@REM Install DataLab and its dependencies
37+
%PYTHON% -m pip install .[exe]
38+
2639
@REM Generating icon
2740
set INKSCAPE_PATH="C:\Program Files\Inkscape\bin\inkscape.exe"
2841
set RESPATH=%CLONEDIR%\resources
@@ -33,7 +46,7 @@ magick "%RESPATH%\tmp-*.png" "%RESPATH%\DataLab.ico"
3346
del "%RESPATH%\tmp-*.png"
3447

3548
@REM Building executable
36-
pyinstaller DataLab.spec --noconfirm --clean
49+
%PYTHON% -m PyInstaller DataLab.spec --noconfirm --clean
3750

3851
@REM Windows 7 SP1 compatibility fix
3952
copy "%RESPATH%\api-ms-win-core-path-l1-1-0.dll" "dist\DataLab\_internal" /Y
@@ -50,5 +63,10 @@ move %CLONEDIR%\dist\%ZIPNAME% %REPODIR%\dist
5063
@REM Move generated folder to dist directory
5164
move %CLONEDIR%\dist\DataLab %REPODIR%\dist
5265

66+
@REM Cleanup temporary directories
5367
rmdir /s /q %CLONEDIR%
68+
rmdir /s /q %VENV_DIR%
69+
@REM Restore PYTHONPATH
70+
set PYTHONPATH=%OLD_PYTHONPATH%
71+
5472
call %FUNC% EndOfScript

0 commit comments

Comments
 (0)