forked from ImSwitch/ImSwitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imswitch.spec
109 lines (94 loc) · 3.46 KB
/
imswitch.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
# -*- mode: python ; coding: utf-8 -*-
import os
import sys
import time
from PyInstaller.building.api import TOC, PYZ, EXE, COLLECT
from PyInstaller.building.build_main import Analysis, BUNDLE
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
from vispy.app.backends import CORE_BACKENDS
print('!IMPORTANT! This will create a bundle based on the current ImSwitch installation. If'
' ImSwitch is not installed to your site packages, or if you have an old version, this may'
' lead to unexpected results. You should always have ImSwitch installed in editable mode'
' ("pip install -e .") before running this. [Continuing in 5 seconds.]')
time.sleep(5)
mainFilePath = '.build_temp/__pyinstaller_main.py'
mainFileScript = '''
import os
os.environ['IMSWITCH_IS_BUNDLE'] = '1'
import imswitch.__main__
imswitch.__main__.main()
'''
datas = []
datas += collect_data_files('imswitch')
datas += collect_data_files('napari')
datas += collect_data_files('vispy')
hiddenImports = []
hiddenImports += collect_submodules('imswitch')
hiddenImports += collect_submodules('napari.utils')
hiddenImports += collect_submodules('pyqtgraph.console')
hiddenImports += ['vispy.ext._bundled.six']
hiddenImports += ['vispy.app.backends.' + b[1] for b in CORE_BACKENDS]
hiddenImports += ['vispy.app.backends._test']
blockCipher = None
try:
os.makedirs(os.path.dirname(mainFilePath), exist_ok=True)
with open(mainFilePath, 'w') as mainFile:
mainFile.write(mainFileScript)
a = Analysis([mainFilePath],
binaries=[],
datas=datas,
hiddenimports=hiddenImports,
hookspath=[],
runtime_hooks=[],
excludes=['matplotlib'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=blockCipher,
noarchive=False)
a.binaries = TOC([x for x in a.binaries if (
not x[0].lower().startswith('api-ms-') and
not x[0].lower().startswith('d3dcompiler') and
not x[0].lower().startswith('msvcp') and
not x[0].lower().startswith('ucrtbase') and
not x[0].lower().startswith('vcomp') and
not x[0].lower().startswith('vcruntime')
)])
pyz = PYZ(a.pure, a.zipped_data,
cipher=blockCipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='ImSwitch',
icon='imswitch/_data/icon.ico',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True)
if sys.platform != 'darwin':
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='ImSwitch')
else:
app = BUNDLE(exe,
a.binaries,
a.zipfiles,
a.datas,
name='ImSwitch.app',
icon=None,
bundle_identifier=None,
info_plist={
'NSPrincipalClass': 'NSApplication',
'NSHighResolutionCapable': 'True'
})
finally:
try:
os.remove(mainFilePath)
except Exception:
pass