-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_script.py
115 lines (80 loc) · 3.02 KB
/
build_script.py
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
import sys
from subprocess import run
def main():
if len(sys.argv) < 2:
print("Usage: python build_script.py <version>")
return
version = sys.argv[1]
print("Building AutoMarker version: " + version + " for Windows...")
# run pyinstaller
run(["pyinstaller", "automarker_win.spec", "--noconfirm"])
# write script.nsi file with version
with open("script.nsi", "w") as f:
f.write(
f"""
; The name of the installer
Name "AutoMarker"
; The file to write
OutFile "dist\\AutoMarker_{version}.exe"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel admin
; Build Unicode installer
Unicode True
; The default installation directory
InstallDir $PROGRAMFILES\\AutoMarker
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\\NSIS_Example2\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AutoMarker" "Install_Dir"
; Import modern ui
!include "MUI2.nsh"
;--------------------------------
; Pages
!define MUI_ICON "icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "icon.bmp"
!define MUI_HEADERIMAGE_RIGHT
!define MUI_PAGE_HEADER_TEXT "Welcome to AutoMarker"
!define MUI_PAGE_HEADER_SUBTEXT "This wizard will guide you through the installation process."
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
; The stuff to install
Section "AutoMarker (required)"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File /nonfatal /a /r "dist\\automarker\\*.*"
WriteUninstaller "$INSTDIR\\uninstall.exe"
; Write the installation path into the registry
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AutoMarker" \\
"DisplayName" "AutoMarker"
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AutoMarker" \\
"UninstallString" "$\\"$INSTDIR\\uninstall.exe$\\""
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AutoMarker" \\
"DisplayIcon" "$INSTDIR\\_internal\\icon.ico"
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateShortcut "$SMPROGRAMS\\AutoMarker.lnk" "$INSTDIR\\AutoMarker.exe"
SectionEnd
;--------------------------------
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AutoMarker"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\\AutoMarker.lnk"
; Remove directories
RMDir /r "$INSTDIR"
SectionEnd
"""
)
print("Building installer...")
# run makensis
run(["C:\\Program Files (x86)\\NSIS\\makensis.exe", "/V4", "script.nsi"])
print("Done!")
if __name__ == "__main__":
main()