forked from Tribler/tribler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tribler.spec
155 lines (130 loc) · 5.62 KB
/
tribler.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
# -*- mode: python -*-
block_cipher = None
import imp
import os
import pkgutil
import sys
import shutil
import aiohttp_apispec
import sentry_sdk
root_dir = os.path.abspath(os.path.dirname(__name__))
src_dir = os.path.join(root_dir, "src")
tribler_components = [
os.path.join(src_dir, "pyipv8"),
os.path.join(src_dir, "anydex"),
os.path.join(src_dir, "tribler-common"),
os.path.join(src_dir, "tribler-core"),
os.path.join(src_dir, "tribler-gui"),
]
for component in tribler_components:
sys.path.append(str(component))
from tribler_core.version import version_id
version_str = version_id.split('-')[0]
from tribler_core.modules.ipv8_module_catalog import get_hiddenimports as ipv8_module_imports
# On macOS, we always show the console to prevent the double-dock bug (although the OS does not actually show the console).
# See https://github.com/Tribler/tribler/issues/3817
show_console = os.environ.get('SHOW_CONSOLE', 'false') == 'true'
if sys.platform == 'darwin':
show_console = True
widget_files = []
for file in os.listdir(os.path.join(src_dir, "tribler-gui", "tribler_gui", "widgets")):
if file.endswith(".py"):
widget_files.append('tribler_gui.widgets.%s' % file[:-3])
data_to_copy = [
(os.path.join(src_dir, "tribler-gui", "tribler_gui", "qt_resources"), 'qt_resources'),
(os.path.join(src_dir, "tribler-gui", "tribler_gui", "images"), 'images'),
(os.path.join(src_dir, "tribler-core", "tribler_core"), 'tribler_source/tribler_core'),
(os.path.join(src_dir, "tribler-gui", "tribler_gui"), 'tribler_source/tribler_gui'),
(os.path.join(root_dir, "build", "win", "resources"), 'tribler_source/resources'),
(os.path.dirname(aiohttp_apispec.__file__), 'aiohttp_apispec')
]
# For bitcoinlib, we have to copy the data directory to the root directory of the installation dir, otherwise
# the library is unable to find the data files.
try:
bitcoinlib_dir = imp.find_module('bitcoinlib')[1]
data_to_copy += [(bitcoinlib_dir, 'bitcoinlib')]
except ImportError:
pass
# Importing lib2to3 as hidden import does not import all the necessary files for some reason so had to import as data.
try:
lib2to3_dir = imp.find_module('lib2to3')[1]
data_to_copy += [(lib2to3_dir, 'lib2to3')]
except ImportError:
pass
if sys.platform.startswith('darwin'):
# Create the right version info in the Info.plist file
with open('build/mac/resources/Info.plist', 'r') as f:
content = f.read()
content = content.replace('__VERSION__', version_str)
os.unlink('build/mac/resources/Info.plist')
with open('build/mac/resources/Info.plist', 'w') as f:
f.write(content)
excluded_libs = ['wx', 'bitcoinlib', 'PyQt4', 'FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter', 'matplotlib']
# Pony dependencies; each packages need to be added separatedly; added as hidden import
pony_deps = ['pony', 'pony.orm', 'pony.orm.dbproviders', 'pony.orm.dbproviders.sqlite']
# Sentry hidden imports
def get_sentry_hooks():
package = sentry_sdk.integrations
sentry_hooks = ['sentry_sdk', 'sentry_sdk.integrations']
for _, modname, _ in pkgutil.walk_packages(path=package.__path__,
prefix=package.__name__ + '.',
onerror=lambda x: None):
sentry_hooks.append(modname)
return sentry_hooks
# Hidden imports
hiddenimports = [
'csv',
'ecdsa',
'pyaes',
'scrypt', '_scrypt',
'sqlalchemy', 'sqlalchemy.ext.baked', 'sqlalchemy.ext.declarative',
'pkg_resources', 'pkg_resources.py2_warn', # Workaround PyInstaller & SetupTools, https://github.com/pypa/setuptools/issues/1963
'requests',
'PyQt5.QtTest',
'pyqtgraph'] + widget_files + pony_deps + list(ipv8_module_imports()) + get_sentry_hooks()
sys.modules['FixTk'] = None
a = Analysis(['src/run_tribler.py'],
pathex=[''],
binaries=None,
datas=data_to_copy,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=excluded_libs,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
# Add libsodium.dylib on OS X
if sys.platform == 'darwin':
a.binaries = a.binaries - TOC([('/usr/local/lib/libsodium.so', None, None),])
a.binaries = a.binaries + TOC([('libsodium.dylib', '/usr/local/lib/libsodium.dylib', None),])
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='tribler',
debug=False,
strip=False,
upx=True,
console=show_console,
icon='build/win/resources/tribler.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='tribler')
app = BUNDLE(coll,
name='tribler.app',
icon='build/mac/resources/tribler.icns',
bundle_identifier='nl.tudelft.tribler',
info_plist={'NSHighResolutionCapable': 'True', 'CFBundleInfoDictionaryVersion': 1.0, 'CFBundleVersion': version_str, 'CFBundleShortVersionString': version_str},
console=show_console)
# Replace the Info.plist file on MacOS
if sys.platform == 'darwin':
shutil.copy('build/mac/resources/Info.plist', 'dist/Tribler.app/Contents/Info.plist')
# On Windows 10, we have to make sure that qwindows.dll is in the right path
if sys.platform == 'win32':
shutil.copytree(os.path.join('dist', 'tribler', 'PyQt5', 'Qt', 'plugins', 'platforms'), os.path.join('dist', 'tribler', 'platforms'))