-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyinstaller.py
64 lines (52 loc) · 1.37 KB
/
pyinstaller.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
import errno
import os
import shutil
from pathlib import Path
import PyInstaller.__main__
from app.constants import name
def remove_directory(path):
try:
shutil.rmtree(path)
except OSError as e:
if e.errno == errno.ENOENT:
pass
else:
raise
main_file = 'main.py'
base_dir = Path(__file__).parent.absolute()
entry_d = os.path.join(base_dir, name)
entry = os.path.join(entry_d, main_file)
build_d = os.path.join(base_dir, 'build')
dist_d = os.path.join(base_dir, 'dist')
ico = '../app.ico'
remove_directory(build_d)
remove_directory(dist_d)
# def flatten(src, out):
# directory = os.path.dirname(out)
# os.makedirs(directory, exist_ok=True)
# s = stickytape.script(src)
# with open(out, 'w') as f:
# f.write(s)
#
#
# def minify(src_dir, out_dir):
# os.makedirs(out_dir, exist_ok=True)
# python_project_minify.directory(src_dir, out_dir)
def install(entry_point=entry):
PyInstaller.__main__.run([
entry_point,
'--noconfirm',
'--name=myWellnezz',
'--onefile',
f'--icon={ico}',
'--clean',
'--optimize=1',
'--noupx',
'--specpath=build',
f'--copy-metadata={name}',
'--copy-metadata=importlib_metadata'
])
if __name__ == '__main__':
# minify(entry_d, build_m_d)
# flatten(build_m, build)
install(entry)