Repository navigation
Expand file tree
/
Copy pathbuild.cmd
More file actions
131 lines (117 loc) · 4.53 KB
/
Copy pathbuild.cmd
File metadata and controls
131 lines (117 loc) · 4.53 KB
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
@echo off
rem Build a distributable pyflashgui: a PyInstaller one-directory build, checked,
rem then wrapped in a Windows installer with Inno Setup.
rem
rem build.cmd build, check, and make setup.exe
rem build.cmd nosetup stop after the checked one-directory build
rem build.cmd setup only make setup.exe, from the dist\pyflashgui already
rem there -- which CI has had signed in between
rem
rem The tests run first, unless WINDOWS_TESTS_PASSED is set to 1: that is CI
rem saying its Windows test job has already passed for this commit, which the
rem installer job waits for. Nothing on your own machine sets it.
rem
rem Two notes for editing this file: batch files must keep CRLF line endings or
rem cmd.exe mis-parses labels and goto (.gitattributes enforces it), and
rem "if errorlevel 1 goto :fail" is used rather than "|| goto :fail", which is
rem unreliable after a quoted interpreter invocation.
setlocal
cd /d "%~dp0"
set PYTHON=.venv\Scripts\python.exe
if /i "%~1"=="setup" goto :setup
echo.
echo === Environment ===================================================
if not exist "%PYTHON%" (
echo Creating the virtual environment in .venv. First time only, and it
echo downloads a couple of hundred megabytes -- Qt is most of it -- so on a
echo slow connection this takes several minutes.
python -m venv .venv
if errorlevel 1 goto :fail
"%PYTHON%" -m pip install --upgrade pip
if errorlevel 1 goto :fail
) else (
echo Using the existing .venv.
)
echo Installing pyflashgui, its dependencies and PyInstaller...
"%PYTHON%" -m pip install -e ".[dev]"
if errorlevel 1 goto :fail
"%PYTHON%" -m pip install pyinstaller
if errorlevel 1 goto :fail
echo.
echo === Tests =========================================================
if "%WINDOWS_TESTS_PASSED%"=="1" goto :tested
rem -n auto: a thousand Qt tests split cleanly across processes.
"%PYTHON%" -m pytest -q -n auto tests
if errorlevel 1 goto :fail
goto :notices
:tested
echo Already passed on Windows for this commit, so not run again.
:notices
echo.
echo === Third party notices ===========================================
"%PYTHON%" build\notices.py
if errorlevel 1 goto :fail
echo.
echo === PyInstaller ===================================================
rmdir /s /q dist\pyflashgui 2>nul
"%PYTHON%" -m PyInstaller --noconfirm --clean --distpath dist --workpath build\work build\pyflashgui.spec
if errorlevel 1 goto :fail
echo.
echo === Checks ========================================================
"%PYTHON%" build\check_build.py
if errorlevel 1 goto :fail
if /i "%~1"=="nosetup" goto :done
:setup
if not exist dist\pyflashgui\pyflashgui.exe (
echo There is no dist\pyflashgui to package: run build.cmd nosetup first.
goto :fail
)
rem The version comes from git: a tag is built as the tag, and refused if it
rem disagrees with pyflashgui.__version__; anything else is a -dev build named
rem after its commit. build\version.py says how. Read through a file: nesting
rem quotes inside a for /f is parsed differently by cmd depending on context,
rem and comes out empty.
set VERSION=
set FILEVERSION=
set VERSIONFILE=%TEMP%\pyflashgui_version.txt
"%PYTHON%" build\version.py > "%VERSIONFILE%"
if errorlevel 1 goto :fail
set /p VERSION=<"%VERSIONFILE%"
"%PYTHON%" build\version.py --file > "%VERSIONFILE%"
if errorlevel 1 goto :fail
set /p FILEVERSION=<"%VERSIONFILE%"
del "%VERSIONFILE%" 2>nul
if not defined VERSION (
echo Could not work out the version.
goto :fail
)
echo.
echo === Installer =====================================================
echo Version %VERSION%
rem Newest first, then whatever is on the PATH, so this keeps working across
rem Inno Setup versions without being edited.
set ISCC=
for %%p in (
"%ProgramFiles(x86)%\Inno Setup 7\ISCC.exe"
"%ProgramFiles%\Inno Setup 7\ISCC.exe"
"%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe"
"%ProgramFiles%\Inno Setup 6\ISCC.exe"
) do if exist %%p if not defined ISCC set ISCC=%%p
if not defined ISCC for %%p in (ISCC.exe) do if not "%%~$PATH:p"=="" set ISCC="%%~$PATH:p"
if not defined ISCC (
echo Inno Setup was not found, so no setup.exe was made.
echo The application itself is ready in dist\pyflashgui.
echo Install it from https://jrsoftware.org/isinfo.php to build one.
goto :done
)
%ISCC% /DAppVersion=%VERSION% /DFileVersion=%FILEVERSION% build\installer.iss
if errorlevel 1 goto :fail
echo Installer: dist\pyflashgui-%VERSION%-setup.exe
:done
echo.
echo Application: dist\pyflashgui\pyflashgui.exe
exit /b 0
:fail
echo.
echo BUILD FAILED ^(errorlevel %errorlevel%^)
exit /b 1