forked from pytrip/pytripgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.spec
157 lines (143 loc) · 4.57 KB
/
main.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- mode: python -*-
# one directory installation:
# might be useful when combined with installer generator such as http://www.innosetup.com/isinfo.php
# following https://github.com/FCS-analysis/PyCorrFit/blob/master/freeze_pyinstaller/PyCorrFit_win7.spec
# patch matplotlib rc file to include only one backend which results in smaller size of generated files
import matplotlib
mplrc = matplotlib.matplotlib_fname()
print(mplrc)
with open(mplrc) as fd:
data = fd.readlines()
for ii, l in enumerate(data):
if l.strip().startswith("backend "):
data[ii] = "backend : Qt5Agg\n"
with open(mplrc, "w") as fd:
fd.writelines(data)
# following https://github.com/FCS-analysis/PyCorrFit/blob/master/freeze_pyinstaller/PyCorrFit_win7.spec
# add current dir to PYTHONPATH, to enable importing pytripgui package
import sys
DIR = os.path.realpath(".")
sys.path.append(DIR)
import pytripgui
# get version string
version = pytripgui.__version__
# following https://github.com/FCS-analysis/PyCorrFit/blob/master/freeze_pyinstaller/PyCorrFit_win7.spec
# replace
## Create inno setup .iss file
import codecs
import platform
filename = "win_innosetup.iss"
issfile = codecs.open(filename, 'r', "utf-8")
iss = issfile.readlines()
issfile.close()
for i,item in enumerate(iss):
if item.strip().startswith("#define MyAppVersion"):
iss[i] = '#define MyAppVersion "{:s}"\n'.format(version)
if item.strip().startswith("#define MyAppPlatform"):
# sys.maxint returns the same for windows 64bit verions
iss[i] = '#define MyAppPlatform "win_{}"\n'.format(platform.architecture()[0])
nissfile = codecs.open(filename, 'wb', "utf-8")
nissfile.writelines(iss)
nissfile.close()
exclude_modules = [
"_asyncio",
"_bz2",
"_decimal",
"_elementtree",
"_hashlib",
"_lzma",
"_overlapped",
"_queue",
"_tkinter",
'pywin.debugger',
'IPython'
]
exclude = [
"d3dcompiler_47.dll",
"libcrypto-1_1-x64.dll",
"libcrypto-1_1.dll",
"libEGL.dll",
"libGLESv2.dll",
"libssl-1_1-x64.dll",
"libssl-1_1.dll",
"opengl32sw.dll",
"Qt5DBus.dll",
"Qt5Network.dll",
"Qt5Qml.dll",
"Qt5QmlModels.dll",
"Qt5Quick.dll",
"Qt5Svg.dll",
"Qt5WebSockets.dll",
"tcl86t.dll",
"tk86t.dll"
]
exclude_startswith = [
"PyQt5\\Qt5\\plugins\\imageformats",
"PyQt5\\Qt5\\plugins\\iconengines"
]
a = Analysis(['pytripgui\\main.py'],
pathex=['.'],
binaries=[],
datas=[('pytripgui/res/*', 'pytripgui/res'),
('pytripgui/view/*.ui', 'pytripgui/view'),
('pytripgui/VERSION', '.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=exclude_modules,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None)
a.binaries = TOC([b for b in a.binaries if b[0] not in exclude])
for e in exclude_startswith:
a.binaries = TOC([b for b in a.binaries if not b[0].startswith(e)])
print("=======================================================================")
print("Binaries:")
for bin in a.binaries:
print(bin)
print("=======================================================================")
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='pytripgui',
debug=False,
strip=False,
upx=False,
console=False,
icon='pytripgui/res/icon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='pytripgui')
# one file installation, nice but application has a slow start as each execution is related to unpacking of ~100MB archive
#a = Analysis(['pytripgui\\main.py'],
# pathex=['.'],
# binaries=[],
# datas=[('pytripgui/res/*', 'res')],
# hiddenimports=[],
# hookspath=[],
# runtime_hooks=[],
# excludes=exclude_modules,
# win_no_prefer_redirects=False,
# win_private_assemblies=False,
# cipher=None)
#
# a.binaries = TOC([b for b in a.binaries if b[0] not in exclude])
# for e in exclude_startswith:
# a.binaries = TOC([b for b in a.binaries if not b[0].startswith(e)])
#
#pyz = PYZ(a.pure)
#exe = EXE(pyz,
# a.scripts,
# a.binaries,
# a.zipfiles,
# a.datas,
# name='pytripgui',
# debug=False,
# strip=False,
# upx=True,
# console=False)