-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
41 lines (32 loc) · 1.32 KB
/
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
39
40
41
# -*- coding: UTF-8 -*-
'''打包成可执行文件
'''
import os
import sys
def main(version):
version_items = version.split('.')
for i in range(len(version_items)):
version_items[i] = int(version_items[i])
with open('version.py', 'w') as fp:
fp.write('version_info=u"%s"' % version)
if sys.platform == 'win32':
version_file_path = 'version_file.txt'
with open(os.path.join('res', 'file_version_info.txt'), 'r') as fp:
text = fp.read()
text = text % {'main_ver': version_items[0],
'sub_ver': version_items[1],
'min_ver': version_items[2],
'build_num': version_items[3] if len(version_items) > 3 else 0
}
with open(version_file_path, 'w') as fp:
fp.write(text)
cmdline = 'pyinstaller -F -w ui/app.py -n WaterInflowPredictor_v%s -i res/meilaoban.ico --hidden-import sklearn.neighbors.typedefs ' \
'--version-file %s' % (version, version_file_path)
else:
cmdline = 'pyinstaller -F -w ui/app.py -n WaterInflowPredictor -i res/meilaoban.icns '
os.system(cmdline)
if __name__ == '__main__':
if len(sys.argv) < 2:
print('usage: python build.py versions')
exit()
main(sys.argv[1])