forked from Tribler/tribler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tribler.spec
105 lines (85 loc) · 3.89 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
# -*- mode: python -*-
block_cipher = None
import imp
import os
import sys
import shutil
sys.path.insert(0, os.getcwdu())
from Tribler.Core.version import version_id
version_str = version_id.split('-')[0]
# 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 = False
if sys.platform == 'darwin':
show_console = True
widget_files = []
for file in os.listdir("TriblerGUI/widgets"):
if file.endswith(".py"):
widget_files.append('TriblerGUI.widgets.%s' % file[:-3])
data_to_copy = [('TriblerGUI/qt_resources', 'qt_resources'), ('TriblerGUI/images', 'images'), ('twisted', 'twisted'), ('Tribler', 'tribler_source/Tribler'), ('logger.conf', '.')]
# 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
if sys.platform.startswith('darwin'):
data_to_copy += [('/Applications/VLC.app/Contents/MacOS/lib', 'vlc/lib'), ('/Applications/VLC.app/Contents/MacOS/plugins', 'vlc/plugins')]
# Create the right version info in the Info.plist file
with open('Tribler/Main/Build/Mac/Info.plist', 'r') as f:
content = f.read()
content = content.replace('__VERSION__', version_str)
os.unlink('Tribler/Main/Build/Mac/Info.plist')
with open('Tribler/Main/Build/Mac/Info.plist', 'w') as f:
f.write(content)
excluded_libs = ['wx', 'bitcoinlib', 'PyQt4']
# We use plyvel on Windows since leveldb is unable to deal with unicode paths
if sys.platform == 'win32':
excluded_libs.append('leveldb')
# 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']
a = Analysis(['run_tribler.py'],
pathex=['/Users/martijndevos/Documents/tribler'],
binaries=None,
datas=data_to_copy,
hiddenimports=['csv', 'ecdsa', 'pyaes', 'scrypt', '_scrypt', 'sqlalchemy', 'sqlalchemy.ext.baked', 'sqlalchemy.ext.declarative', 'requests', 'PyQt5.QtTest'] + widget_files + pony_deps,
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='Tribler/Main/Build/Win/tribler.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='tribler')
app = BUNDLE(coll,
name='tribler.app',
icon='Tribler/Main/Build/Mac/tribler.icns',
bundle_identifier='nl.tudelft.tribler',
info_plist={'NSHighResolutionCapable': 'True', 'CFBundleInfoDictionaryVersion': 1.0, 'CFBundleVersion': version_str, 'CFBundleShortVersionString': version_str},
console=show_console)
# Remove the test directories in the Tribler source code
shutil.rmtree(os.path.join(DISTPATH, 'tribler', 'tribler_source', 'Tribler', 'Test'))
# Replace the Info.plist file on MacOS
if sys.platform == 'darwin':
shutil.copy('Tribler/Main/Build/Mac/Info.plist', 'dist/Tribler.app/Contents/Info.plist')