forked from raiden-network/raiden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raiden.spec
156 lines (138 loc) · 3.77 KB
/
raiden.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
# -*- mode: python -*-
from __future__ import print_function
import pdb
import platform
import sys
from raiden.utils.system import get_system_spec
"""
PyInstaller spec file to build single file or dir distributions
"""
# Set to false to produce an exploded single-dir
ONEFILE = int(os.environ.get("ONEFILE", True))
def Entrypoint(
dist,
group,
name,
scripts=None,
pathex=None,
hiddenimports=None,
hookspath=None,
excludes=None,
runtime_hooks=None,
datas=None,
):
import pkg_resources
# get toplevel packages of distribution from metadata
def get_toplevel(dist):
distribution = pkg_resources.get_distribution(dist)
if distribution.has_metadata("top_level.txt"):
return list(distribution.get_metadata("top_level.txt").split())
else:
return []
hiddenimports = hiddenimports or []
packages = []
for distribution in hiddenimports:
try:
packages += get_toplevel(distribution)
except:
pass
scripts = scripts or []
pathex = pathex or []
# get the entry point
ep = pkg_resources.get_entry_info(dist, group, name)
# insert path of the egg at the verify front of the search path
pathex = [ep.dist.location] + pathex
# script name must not be a valid module name to avoid name clashes on import
script_path = os.path.join(workpath, name + "-script.py")
print("creating script for entry point", dist, group, name)
with open(script_path, "w") as fh:
print("import", ep.module_name, file=fh)
print("%s.%s()" % (ep.module_name, ".".join(ep.attrs)), file=fh)
for package in packages:
print("import", package, file=fh)
analysis = Analysis(
[script_path] + scripts,
pathex=pathex,
hiddenimports=hiddenimports,
hookspath=hookspath,
excludes=excludes,
runtime_hooks=runtime_hooks,
datas=datas,
)
return analysis
if hasattr(pdb, "pdb"):
# pdbpp moves the stdlib pdb to the `pdb` attribute of it's own patched pdb module
raise RuntimeError(
"pdbpp is installed which causes broken PyInstaller builds. Please uninstall it.",
)
# We don't need Tk and friends
sys.modules["FixTk"] = None
executable_name = "raiden-{}-{}-{}".format(
os.environ.get("ARCHIVE_TAG", "v" + get_system_spec()["raiden"]),
"macOS" if platform.system() == "Darwin" else platform.system().lower(),
platform.machine(),
)
a = Entrypoint(
"raiden",
"console_scripts",
"raiden",
hookspath=["tools/pyinstaller_hooks"],
runtime_hooks=[
"tools/pyinstaller_hooks/runtime_gevent_monkey.py",
"tools/pyinstaller_hooks/runtime_aiortc_pyav_stub.py",
"tools/pyinstaller_hooks/runtime_encoding.py",
"tools/pyinstaller_hooks/runtime_raiden_contracts.py",
],
hiddenimports=[
"aiortc_pyav_stub",
],
datas=[],
excludes=[
"_tkinter",
"av",
"FixTk",
"ipython",
"jupyter",
"jupyter_core",
"notebook",
"tcl",
"tk",
"tkinter",
"Tkinter",
],
)
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
if ONEFILE:
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=executable_name,
debug=False,
strip=False,
upx=False,
runtime_tmpdir=None,
console=True,
)
else:
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name=executable_name,
debug="all",
strip=False,
upx=False,
console=True,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name="raiden",
)