-
Notifications
You must be signed in to change notification settings - Fork 19
/
deeplc_pyinstaller.spec
121 lines (107 loc) · 2.93 KB
/
deeplc_pyinstaller.spec
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import os
import os
import sys
import importlib.metadata
from PyInstaller.utils.hooks import collect_all
from PyInstaller.building.build_main import Analysis, PYZ, EXE, COLLECT, Tree
import gooey
from deeplc import __version__
# Package info
exe_name = "deeplc"
script_name = "deeplc/gui.py"
if sys.platform[:6] == "darwin":
icon = './img/deeplc.icns'
else:
icon = './img/deeplc.ico'
block_cipher = None
location = os.getcwd()
project = "deeplc"
bundle_name = "deeplc"
bundle_identifier = f"{bundle_name}.{__version__}"
# Collect hidden imports and datas for all requirements
requirements = {req.split()[0] for req in importlib.metadata.requires(project)}
requirements.update([project, "distributed", "sklearn", "gooey"])
hidden_imports = set()
datas = []
binaries = []
checked = set()
while requirements:
requirement = requirements.pop()
checked.add(requirement)
try:
module_version = importlib.metadata.version(requirement)
except (importlib.metadata.PackageNotFoundError, ModuleNotFoundError, ImportError):
if requirement != "sklearn":
continue
try:
datas_, binaries_, hidden_imports_ = collect_all(
requirement, include_py_files=True
)
except ImportError:
continue
datas += datas_
hidden_imports_ = set(hidden_imports_)
if "" in hidden_imports_:
hidden_imports_.remove("")
if None in hidden_imports_:
hidden_imports_.remove(None)
requirements |= hidden_imports_ - checked
hidden_imports |= hidden_imports_
hidden_imports = sorted([h for h in hidden_imports if "tests" not in h.split(".")])
hidden_imports = [h for h in hidden_imports if "__pycache__" not in h]
datas = [d for d in datas if ("__pycache__" not in d[0]) and (d[1] not in [".", "build", "dist", "Output"])]
# Additional Gooey files
gooey_root = os.path.dirname(gooey.__file__)
gooey_languages = Tree(os.path.join(gooey_root, "languages"), prefix="gooey/languages")
gooey_images = Tree(os.path.join(gooey_root, "images"), prefix="gooey/images")
# Build package
a = Analysis(
[script_name],
pathex=[location],
binaries=binaries,
datas=datas,
hiddenimports=hidden_imports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False
)
pyz = PYZ(
a.pure,
a.zipped_data,
cipher=block_cipher
)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name=exe_name,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
windowed=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon="./img/deeplc.ico"
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
gooey_languages,
gooey_images,
strip=False,
upx=True,
upx_exclude=[],
name=exe_name
)