-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathdash_masternode_tool.spec
More file actions
250 lines (220 loc) · 8.11 KB
/
Copy pathdash_masternode_tool.spec
File metadata and controls
250 lines (220 loc) · 8.11 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# -*- mode: python -*-
import importlib
import sys
import os.path
import platform
import subprocess
from PyInstaller.utils.hooks import (collect_data_files, collect_submodules,
collect_dynamic_libs)
block_cipher = None
os_type = sys.platform
no_bits = platform.architecture()[0].replace('bit', '')
version_str = ''
base_dir = os.path.dirname(os.path.abspath('__file__'))
# Check for version string
with open(os.path.join(base_dir, 'version.txt')) as fptr:
for line in fptr:
parts = [elem.strip() for elem in line.split('=')]
if len(parts) == 2 and parts[0].lower() == 'version_str':
version_str = parts[1].strip("'")
break
binary_files = []
data_files = [
('version.txt', '.'),
('app-params.json', '.')
]
# source: https://github.com/akhavr/electrum-dash/blob/master/contrib/osx/osx.spec
hiddenimports = []
# hiddenimports += collect_submodules('pkg_resources') # workaround for https://github.com/pypa/setuptools/issues/1963
hiddenimports += collect_submodules('trezorlib')
hiddenimports += collect_submodules('btchip')
hiddenimports += collect_submodules('keepkeylib')
hiddenimports += collect_submodules('websocket')
hiddenimports += [
'PyQt5.sip',
'usb1',
'backports'
]
def add_data_file(file: str, dest_dir: str):
global data_files
data_files.append((file, dest_dir))
print(f'Adding data file {file} to dest dir {dest_dir}')
def add_binary_file(file: str, dest_dir: str):
global binary_files
binary_files.append((file, dest_dir))
print(f'Adding binary file {file} to dest dir {dest_dir}')
for f in os.listdir(os.path.join(base_dir, 'img')):
f_full = os.path.join(base_dir, 'img', f)
if os.path.isfile(f_full):
add_data_file('img/' + f, 'img')
def find_file_in_dirs(dirs, file_name):
for dir_name in dirs:
file_full_path = os.path.join(dir_name, file_name)
if os.path.exists(file_full_path):
return file_full_path
raise Exception('Unable to find ' + file_name)
lib_paths = [p for p in sys.path if 'site-packages' in p]
add_data_file(find_file_in_dirs(lib_paths, 'bitcoin/english.txt'), 'bitcoin')
if os_type != 'win32': # TODO: find out why on windows sometimes it complains about duplicated english.txt
add_data_file(find_file_in_dirs(lib_paths, 'mnemonic/wordlist/english.txt'), 'mnemonic/wordlist')
add_data_file(find_file_in_dirs(lib_paths, 'trezorlib/transport'), 'trezorlib/transport')
excludes = [
'PyQt5.QtBluetooth',
'PyQt5.QtCLucene',
'PyQt5.QtDBus',
'PyQt5.Qt5CLucene',
'PyQt5.QtDesigner',
'PyQt5.QtDesignerComponents',
'PyQt5.QtHelp',
'PyQt5.QtLocation',
'PyQt5.QtMultimedia',
'PyQt5.QtMultimediaQuick_p',
'PyQt5.QtMultimediaWidgets',
'PyQt5.QtNetwork',
'PyQt5.QtNetworkAuth',
'PyQt5.QtNfc',
'PyQt5.QtOpenGL',
'PyQt5.QtPositioning',
'PyQt5.QtQml',
'PyQt5.QtQuick',
'PyQt5.QtQuickParticles',
'PyQt5.QtQuickWidgets',
'PyQt5.QtSensors',
'PyQt5.QtSerialPort',
'PyQt5.QtSql',
'PyQt5.Qt5Sql',
'PyQt5.Qt5Svg',
'PyQt5.QtTest',
'PyQt5.QtWebChannel',
'PyQt5.QtWebEngine',
'PyQt5.QtWebEngineCore',
'PyQt5.QtWebEngineWidgets',
'PyQt5.QtWebKit',
'PyQt5.QtWebKitWidgets',
'PyQt5.QtWebSockets',
'PyQt5.QtXml',
'PyQt5.QtXmlPatterns',
'PyQt5.QtWebProcess',
'PyQt5.QtWinExtras',
]
data_files += collect_data_files('trezorlib')
data_files += collect_data_files('btchip')
data_files += collect_data_files('keepkeylib')
if os_type == 'darwin':
libusb_path = '/opt/homebrew/lib/libusb-1.0.dylib'
if not os.path.exists(libusb_path):
libusb_path = '/usr/local/lib/libusb-1.0.dylib'
if not os.path.exists(libusb_path):
# Try to find using brew --prefix
try:
prefix = subprocess.check_output(['brew', '--prefix'], encoding='utf-8').strip()
libusb_path = os.path.join(prefix, 'lib', 'libusb-1.0.dylib')
except Exception:
pass
if os.path.exists(libusb_path):
add_binary_file(libusb_path, '.')
else:
print('WARNING: libusb-1.0.dylib not found!!')
elif os_type == 'linux':
try:
lib_path = find_file_in_dirs(('/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu'),
'libxcb-xinerama.so.0')
add_binary_file(lib_path, '.')
except Exception as e:
print(f'WARNING: libxcb-xinerama.so.0 not found: {str(e)}')
elif os_type == 'win32':
mod = importlib.import_module('usb1')
if mod and mod.__path__:
libusb_full_path = os.path.join(mod.__path__[0], 'libusb-1.0.dll')
if not os.path.isfile(libusb_full_path):
import ctypes.util
libusb_full_path = ctypes.util.find_library('libusb-1.0.dll')
if libusb_full_path:
add_binary_file(libusb_full_path, '.')
print('found libusb library: ' + libusb_full_path)
else:
print('WARNING: libusb-1.0.dll not found!!')
a = Analysis(['src/dash_masternode_tool.py'],
pathex=[base_dir],
binaries=binary_files,
datas=data_files,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=excludes,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
if os_type == 'darwin':
# One-dir mode on macOS: avoids per-launch extraction of a one-file archive
# to /tmp/_MEIxxxxxx, which combined with Gatekeeper scanning makes cold
# starts take a minute or more. The .app bundle wraps the collected dir.
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='DashMasternodeTool',
debug=False,
strip=False,
upx=False,
console=False,
icon=os.path.join('img', 'dmt.icns'))
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='DashMasternodeTool')
app = BUNDLE(coll,
name='DashMasternodeTool.app',
icon='img/dmt.icns',
bundle_identifier=None,
info_plist={
'NSHighResolutionCapable': 'True'
}
)
else:
# One-file mode on Windows and Linux.
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='DashMasternodeTool',
debug=False,
strip=False,
upx=False,
console=False,
icon=os.path.join('img', 'dmt.ico'))
dist_path = os.path.join(base_dir, DISTPATH)
all_bin_dir = os.path.join(dist_path, '..', 'all')
if not os.path.exists(all_bin_dir):
os.makedirs(all_bin_dir)
# Zip archives
os.chdir(dist_path)
if os_type == 'win32':
print('Compressing Windows executable')
archive_file = os.path.join(all_bin_dir, 'DashMasternodeTool_' + version_str + '.win' + no_bits + '.zip')
os.system('"7z.exe" a %s %s -mx0' % (archive_file, 'DashMasternodeTool.exe'))
print('Created archive: ' + archive_file)
elif os_type == 'darwin':
print('Compressing Mac executable')
arch = platform.machine().lower()
if arch in ['x86_64', 'amd64']:
arch_suffix = '.mac-x64.zip'
elif arch in ['arm64', 'aarch64']:
arch_suffix = '.mac-arm64.zip'
else:
arch_suffix = '.mac-' + arch + '.zip'
archive_file = os.path.join(all_bin_dir, 'DashMasternodeTool_' + version_str + arch_suffix)
os.system('zip -r "%s" "%s"' % (archive_file, 'DashMasternodeTool.app'))
print('Created archive: ' + archive_file)
elif os_type == 'linux':
print('Compressing Linux executable')
archive_file = os.path.join(all_bin_dir, 'DashMasternodeTool_' + version_str + '.linux.tar.gz')
os.system('tar -zcvf %s %s' % (archive_file, 'DashMasternodeTool'))
print('Created archive: ' + archive_file)