-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
58 lines (50 loc) · 1.93 KB
/
setup.py
File metadata and controls
58 lines (50 loc) · 1.93 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
import os
import shutil
import subprocess
import sys
from datetime import date
import PyInstaller.__main__
dir_PyCharm = os.path.abspath('.')
dir_path = os.path.abspath('src')
build = os.path.join(dir_PyCharm, 'build\\')
dir_name = os.path.basename(os.path.abspath('.'))
dst = os.path.join('C:/Temp', dir_name)
if os.path.isdir(dst):
shutil.rmtree(dst)
shutil.copytree(dir_path, dst)
# Create file with build date
with open(os.path.join(dir_path, 'resources/build_date.txt'), 'w') as f:
f.write(date.today().strftime('%B {}, %Y'.format(date.today().day)))
# Update script
PyInstaller.__main__.run([
os.path.join(dst, r'scripts/update.py'),
'--workpath', build,
'--specpath', build,
'--distpath', os.path.join(dst, 'scripts'),
'--noconsole',
'-F'
])
# Main script
PyInstaller.__main__.run([
os.path.join(dst, 'main.py'),
'-n', 'Local_Instant_Messenger',
'--workpath', build,
'--specpath', build,
'--distpath', dir_PyCharm,
'-F',
'--noconsole', # Comment out for console to appear when running app
'--icon', os.path.join(dir_path, 'resources', 'Local_Instant_Messenger.ico'),
'--hidden-import', 'wx.adv',
'--hidden-import', 'wx.xml',
# '--add-data', f'{sys.prefix}/Lib/site-packages/wx/WebView2Loader.dll.lib;./wx', # Don't need?
# '--add-data', f'{sys.prefix}/Lib/site-packages/wx/WebView2LoaderStatic.lib;./wx', # Don't need?
'--add-data', f'{sys.prefix}/Lib/site-packages/wx/WebView2Loader.dll;./wx', # Otherwise the chat window doesn't show
'--add-data', f'{sys.prefix}/Lib/site-packages/enchant;./enchant', # Otherwise enchant errors
'--add-data', f'{sys.prefix}/Lib/site-packages/emoji;./emoji', # Otherwise emoji errors
# '--debug=imports',
'--add-data', rf'{dst};.'
])
shutil.rmtree(dst)
pigar_script = (f'cd {dir_PyCharm} '
f'&& {sys.executable} -m pigar generate --question-answer no')
subprocess.run(pigar_script, cwd=dir_PyCharm, shell=True)