-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_executable.py
More file actions
65 lines (49 loc) · 1.54 KB
/
Copy pathgenerate_executable.py
File metadata and controls
65 lines (49 loc) · 1.54 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
59
60
61
62
63
64
65
import os
import PyInstaller.__main__
from pibs import __version__
def generate_executables(mult_file: bool = False):
name = "PIBSv" + __version__
sep = os.pathsep # ':' on POSIX, ';' on Windows
options = [
"run_pibs.py",
"--clean",
"--noconfirm",
"--windowed",
"--icon=pibs/ui/logo.ico",
"--name=" + name,
"--noupx",
f"--add-data=pibs/ballistics/resource{sep}ballistics/resource/",
f"--add-data=pibs/ui{sep}ui/",
f"--add-data=pibs/examples{sep}examples/",
] + (["--onefile"] if not mult_file else [])
PyInstaller.__main__.run(options)
with open(name + ".spec", "r") as f:
content = f.readlines()
with open(name + ".spec", "w") as f:
f.writelines(content)
i = content.index("pyz = PYZ(a.pure)\n")
dll_exclusion = """# exclude excessive DLL collected by pyinstaller
key_words = ['api-ms-win']
new_binaries = []
excluded = []
for item in a.binaries:
name, _, _ = item
to_include = True
for key_word in key_words:
if key_word in name:
to_include = False
if to_include:
new_binaries.append(item)
else:
excluded.append(item)
a.binaries = new_binaries
"""
for line in dll_exclusion.split("\n"):
content.insert(i, line + "\n")
i += 1
with open(name + ".spec", "w") as f:
f.writelines(content)
os.system("pyinstaller " + name + ".spec" + " --noconfirm")
if __name__ == "__main__":
generate_executables(False)
generate_executables(True)