-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
38 lines (34 loc) · 969 Bytes
/
build.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
import os
import sys
import subprocess
def main(argv: list) -> int:
cwd = os.path.dirname(__file__) or os.getcwd()
os.chdir(cwd)
main_path = os.path.join(cwd, 'main.py')
files_dir = os.path.join(cwd, 'files')
icon_path = os.path.join(files_dir, 'gdl_icon.ico')
exe_out_path = os.path.join(cwd, 'dist', 'main.exe')
exe_path = os.path.join(cwd, 'dist', 'GDL_Installer.exe')
if os.path.isfile(exe_path):
os.remove(exe_path)
result = subprocess.call([
'pyinstaller',
'--onefile',
'--uac-admin',
'--add-data',
f'{files_dir};files',
'-w',
'-i',
icon_path,
main_path
] + argv)
if result:
print('build failed')
return result
if not os.path.isfile(exe_out_path):
print('could not find output')
return 1
os.rename(exe_out_path, exe_path)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))