-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.bat
78 lines (65 loc) · 2.08 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
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
@echo off
set MAINFAILENAME=binary-waterfall
set ENVNAME=%MAINFAILENAME%
set BUILDENVNAME=build
set MODULENAME=binary_waterfall
set ORIGDIR=%CD%
set SOURCEDIR=%ORIGDIR%\src\%MODULENAME%
set DISTDIR=%ORIGDIR%\dist
set BUILDDIR=%ORIGDIR%\build
set PY=%ORIGDIR%\%MAINFAILENAME%.py
set SPEC=%ORIGDIR%\%MAINFAILENAME%.spec
set EXE=%DISTDIR%\%MAINFAILENAME%.exe
set TARGETEXE=%ORIGDIR%\%MAINFAILENAME%.exe
set VERSION_YAML=%SOURCEDIR%\version.yml
set VERSION_INFO=%ORIGDIR%\file_version_info.txt
set RESOURCEDIR=%SOURCEDIR%\resources
set ICON_ICO=%RESOURCEDIR%\icon.ico
set SPLASH_IMG=%RESOURCEDIR%\splash.jpg
echo Cleaning up before making release...
del /f /q "%TARGETEXE%" 1>nul 2>&1
del /f /s /q "%DISTDIR%" 1>nul 2>&1
rmdir /s /q "%DISTDIR%" 1>nul 2>&1
del /f /s /q "%BUILDDIR%" 1>nul 2>&1
rmdir /s /q "%BUILDDIR%" 1>nul 2>&1
del /f /q "%SPEC%" 1>nul 2>&1
del /f /q "%VERSION_INFO%" 1>nul 2>&1
echo Building portable EXE...
del /f /s /q "%TARGETEXE%" 1>nul 2>&1
call conda run -n %ENVNAME% create-version-file %VERSION_YAML% --outfile %VERSION_INFO%
if errorlevel 1 goto ERROR
call conda run -n %ENVNAME% pyinstaller ^
--clean ^
--noconfirm ^
--noconsole ^
--add-data %SOURCEDIR%\*.py;.\src\%MODULENAME% ^
--add-data %SOURCEDIR%\version.yml;.\src\%MODULENAME% ^
--add-data %SOURCEDIR%\constants\*.py;.\src\%MODULENAME%\constants ^
--add-data %SOURCEDIR%\helpers\*.py;.\src\%MODULENAME%\helpers ^
--add-data %SOURCEDIR%\resources\*;.\src\%MODULENAME%\resources ^
--onefile ^
--icon=%ICON_ICO% ^
--splash=%SPLASH_IMG% ^
--version-file=%VERSION_INFO% ^
"%PY%"
if errorlevel 1 goto ERROR
echo Cleaning up after making .exe release...
move "%EXE%" "%TARGETEXE%"
del /f /s /q "%DISTDIR%" 1>nul 2>&1
rmdir /s /q "%DISTDIR%" 1>nul 2>&1
del /f /s /q "%BUILDDIR%" 1>nul 2>&1
rmdir /s /q "%BUILDDIR%" 1>nul 2>&1
del /f /q "%SPEC%" 1>nul 2>&1
del /f /q "%VERSION_INFO%" 1>nul 2>&1
echo Making PyPI release...
call conda run -n %BUILDENVNAME% python -m build
if errorlevel 1 goto ERROR
goto DONE
:ERROR
cd %ORIGDIR%
echo Build failed!
exit /B 1
:DONE
cd %ORIGDIR%
echo Build done!
exit /B 0