-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGUniDec.spec
206 lines (163 loc) · 7.87 KB
/
GUniDec.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# -*- mode: python -*-
import os
import pymzml
import datetime
import platform
import zipfile
import time
import fnmatch
from multiprocessing import freeze_support
from os import listdir
from PyInstaller import compat
import matplotlib
import sys
import hashlib
import shutil
def hashfile(path):
# BUF_SIZE is totally arbitrary, change for your app!
BUF_SIZE = 65536 # lets read stuff in 64kb chunks!
md5 = hashlib.md5()
sha256 = hashlib.sha256()
with open(path, 'rb') as f:
while True:
data = f.read(BUF_SIZE)
if not data:
break
md5.update(data)
sha256.update(data)
md5hash = md5.hexdigest()
sha256hash = sha256.hexdigest()
print("MD5: {0}".format(md5hash))
print("SHA256: {0}".format(sha256hash))
return md5hash, sha256hash
freeze_support()
def dir_files(path, rel, type='DATA'):
ret = []
for p, d, f in os.walk(path):
relpath = p.replace(path, '')[1:]
for fname in f:
ret.append((os.path.join(rel, relpath, fname),
os.path.join(p, fname), type))
return ret
# Some basics
tstart = time.perf_counter()
system = platform.system()
date = datetime.date.today().strftime("%y%m%d")
# Create names of files and directories
exename = 'GUI_UniDec'
if system == "Windows":
exename += ".exe"
outputdir = 'UniDec_' + system
zipdirectory = outputdir + "_" + date + ".zip"
hiddenimportslist=['scipy.special._ufuncs_cxx', 'scipy.linalg.cython_blas', 'scipy.linalg.cython_lapack',
'scipy.special.cython_special','numpy',
'scipy._lib.messagestream','clr', 'pythonnet',
'encodings', 'encodings.__init__',
'packaging', 'packaging.version', 'packaging.specifiers',
'pubsub', 'pubsub.core', 'matplotlib.backends.backend_ps', 'matplotlib.backends.backend_pdf',
]
excludeslist = ['IPython', 'statsmodels', 'pyopenms', 'sklearn',
'GdkPixbuf', 'pyQT4', 'pygobject', 'pygtk', 'pyside', 'PySide2', 'shiboken2', 'PyQt5', 'torch']
# Analysis of packages
a = Analysis(['unidec\\Launcher.py'],
pathex=[os.getcwd()],
excludes=excludeslist,
hiddenimports=hiddenimportslist,
hookspath=None,
runtime_hooks=None)
# Add extra things
if system == "Windows":
a.datas += [('UniDec.exe', 'unidec\\bin\\UniDec.exe', 'DATA')]
a.datas += [('readme.md', 'readme.md', 'DATA')]
a.datas += [('LICENSE', 'LICENSE', 'DATA')]
a.datas += [('CDCReader.exe', 'unidec\\bin\\CDCReader.exe', 'DATA')]
a.datas += [('h5repack.exe', 'unidec\\bin\\h5repack.exe', 'DATA')]
a.datas += [('unimod.sqlite', 'unidec\\bin\\unimod.sqlite', 'DATA')]
#a.datas += [('numpy/DLLs', 'unidec\\bin\\mkl_def.2.dll', 'BINARY')]
#a.datas += [('numpy/DLLs', 'unidec\\bin\\mkl_avx2.2.dll', 'BINARY')]
#a.datas += [('numpy/DLLs', 'unidec\\bin\\mkl_intel_thread.2.dll', 'BINARY')]
a.datas += [('pymzml\\version.txt', compat.base_prefix + '\\Lib\\site-packages\\pymzml\\version.txt', 'DATA')]
a.datas += [('massql\\msql.ebnf', compat.base_prefix + '\\Lib\\site-packages\\massql\\msql.ebnf', 'DATA')]
# Copy over all the DLLs from the bin folder
for file in os.listdir('unidec\\bin'):
if fnmatch.fnmatch(file, '*.dll'):
add = [(file, 'unidec\\bin\\' + file, 'BINARY')]
a.datas += add
# print add
a.datas += [('RawFileReaderLicense.doc', 'unidec\\UniDecImporter\\Thermo\\RawFileReaderLicense.doc', 'BINARY')]
a.datas += [('ThermoFisher.CommonCore.Data.dll', 'unidec\\UniDecImporter\\Thermo\\ThermoFisher.CommonCore.Data.dll', 'BINARY')]
a.datas += [('ThermoFisher.CommonCore.RawFileReader.dll', 'unidec\\UniDecImporter\\Thermo\\ThermoFisher.CommonCore.RawFileReader.dll', 'BINARY')]
a.datas += [('ThermoFisher.CommonCore.MassPrecisionEstimator.dll', 'unidec\\UniDecImporter\\Thermo\\ThermoFisher.CommonCore.MassPrecisionEstimator.dll', 'BINARY')]
a.datas += [('ThermoFisher.CommonCore.BackgroundSubtraction.dll', 'unidec\\UniDecImporter\\Thermo\\ThermoFisher.CommonCore.BackgroundSubtraction.dll', 'BINARY')]
a.datas += [('Waters_MassLynxSDK_EULA.txt', 'unidec\\bin\\Waters_MassLynxSDK_EULA.txt', 'DATA')]
a.datas += [('BaseCommon.dll', 'unidec\\UniDecImporter\\Agilent\\BaseCommon.dll', 'BINARY')]
a.datas += [('BaseCommon.tlb', 'unidec\\UniDecImporter\\Agilent\\BaseCommon.tlb', 'BINARY')]
a.datas += [('BaseDataAccess.dll', 'unidec\\UniDecImporter\\Agilent\\BaseDataAccess.dll', 'BINARY')]
a.datas += [('BaseDataAccess.tlb', 'unidec\\UniDecImporter\\Agilent\\BaseDataAccess.tlb', 'BINARY')]
a.datas += [('BaseError.dll', 'unidec\\UniDecImporter\\Agilent\\BaseError.dll', 'BINARY')]
a.datas += [('BaseTof.dll', 'unidec\\UniDecImporter\\Agilent\\BaseTof.dll', 'BINARY')]
a.datas += [('MassSpecDataReader.dll', 'unidec\\UniDecImporter\\Agilent\\MassSpecDataReader.dll', 'BINARY')]
a.datas += [('MassSpecDataReader.tlb', 'unidec\\UniDecImporter\\Agilent\\MassSpecDataReader.tlb', 'BINARY')]
a.datas += [('isodeclib.dll', 'unidec\\IsoDec\\isodeclib.dll', 'BINARY')]
a.datas += [('isodeclib.lib', 'unidec\\IsoDec\\isodeclib.lib', 'BINARY')]
a.datas += [('isogenmass.dll', 'unidec\\IsoDec\\isogenmass.dll', 'BINARY')]
a.datas += [('isogenmass.lib', 'unidec\\IsoDec\\isogenmass.lib', 'BINARY')]
elif system == "Linux":
a.datas += [('unideclinux', 'unidec/bin/unideclinux', 'BINARY')]
a.datas += [('cacert.pem', os.path.join('unidec\\bin', 'cacert.pem'), 'DATA')]
a.datas += [('logo.ico', 'unidec\\bin\\logo.ico', 'DATA')]
a.datas += [('mass_table.csv', 'unidec\\bin\\mass_table.csv', 'DATA')]
a.datas += [('metaunidec/images/allButton.png', 'metaunidec\\images\\allButton.png', 'DATA')]
a.datas += [('metaunidec/images/peakRightClick.png', 'metaunidec\\images\\peakRightClick.png', 'DATA')]
a.datas += [('metaunidec/images/rightClick.png', 'metaunidec\\images\\rightClick.png', 'DATA')]
a.datas += [('UniDecLogoMR.png', 'unidec\\bin\\UniDecLogoMR.png', 'DATA')]
a.datas.extend(dir_files(os.path.join(os.path.dirname(pymzml.__file__), 'obo'), 'obo'))
a.datas.extend(dir_files("unidec\\bin\\Presets", 'Presets'))
a.datas.extend(dir_files("unidec\\bin\\Example Data", 'Example Data'))
a.datas.extend(dir_files(compat.base_prefix + '\\Lib\\site-packages\\matchms\\data', "matchms\\data"))
mkldir = compat.base_prefix + "/Lib/site-packages/numpy/DLLs"
newdir = "numpy/DLLs"
a.datas.extend(dir_files(mkldir, newdir, type="BINARY"))
#a.datas.extend(
# [(mkldir + "/" + mkl, newdir, 'BINARY') for mkl in listdir(mkldir) if mkl.startswith('mkl_') or mkl.startswith('libio')])
# rdkitlibs = compat.base_prefix + "/Lib/site-packages/rdkit.libs"
# a.datas.extend(dir_files(rdkitlibs, ''))
# Assemble and build
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name=exename,
debug=False,
strip=None,
upx=False,
console=True, icon='unidec\\bin\\logo.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=False,
name=outputdir)
path = "C:\\Python\\UniDec3\\dist\\UniDec_Windows\\GUI_UniDec.exe"
import subprocess
dst = "C:\\Python\\UniDec3\\dist\\UniDec_Windows\\obo"
src = "C:\\Python\\UniDec3\\dist\\UniDec_Windows\\_internal\\obo"
shutil.copytree(src, dst)
print("Testing Software...", path)
out = subprocess.call(path)
if out != 0:
exit()
# exit()
print("Zipping...")
# Zip up the final file
os.chdir("dist")
zipf = zipfile.ZipFile(zipdirectory, 'w')
for root, dirs, files in os.walk(outputdir):
for file in files:
zipf.write(os.path.join(root, file), compress_type=zipfile.ZIP_DEFLATED)
zipf.close()
print("Zipped to", zipdirectory, "from", outputdir)
hashfile(zipdirectory)
tend = time.perf_counter()
print("Build Time: %.2gm" % ((tend - tstart) / 60.0))