@@ -12,18 +12,40 @@ PyInstaller spec file to build single file or dir distributions
12
12
"""
13
13
14
14
# Set to false to produce an exploded single-dir
15
- ONEFILE = int (os .environ .get ('ONEFILE' , True ))
16
-
17
-
18
- def Entrypoint (dist , group , name , scripts = None , pathex = None , hiddenimports = None , hookspath = None ,
19
- excludes = None , runtime_hooks = None , datas = None ):
15
+ ONEFILE = int (os .environ .get ("ONEFILE" , True ))
16
+
17
+ # Hack: This is a list of prefixes to be removed from the `binaries`.
18
+ # We do this to prevent including unnecessary libraries (pyav audio / video dependencies)
19
+ BINARIES_PREFIX_BLOCKLIST = [
20
+ "libav" ,
21
+ "libaom" ,
22
+ "libswscale" ,
23
+ "libswrescale" ,
24
+ "libvorbis" ,
25
+ "libx264" ,
26
+ "libx265" ,
27
+ ]
28
+
29
+
30
+ def Entrypoint (
31
+ dist ,
32
+ group ,
33
+ name ,
34
+ scripts = None ,
35
+ pathex = None ,
36
+ hiddenimports = None ,
37
+ hookspath = None ,
38
+ excludes = None ,
39
+ runtime_hooks = None ,
40
+ datas = None ,
41
+ ):
20
42
import pkg_resources
21
43
22
44
# get toplevel packages of distribution from metadata
23
45
def get_toplevel (dist ):
24
46
distribution = pkg_resources .get_distribution (dist )
25
- if distribution .has_metadata (' top_level.txt' ):
26
- return list (distribution .get_metadata (' top_level.txt' ).split ())
47
+ if distribution .has_metadata (" top_level.txt" ):
48
+ return list (distribution .get_metadata (" top_level.txt" ).split ())
27
49
else :
28
50
return []
29
51
@@ -42,54 +64,75 @@ def Entrypoint(dist, group, name, scripts=None, pathex=None, hiddenimports=None,
42
64
# insert path of the egg at the verify front of the search path
43
65
pathex = [ep .dist .location ] + pathex
44
66
# script name must not be a valid module name to avoid name clashes on import
45
- script_path = os .path .join (workpath , name + ' -script.py' )
67
+ script_path = os .path .join (workpath , name + " -script.py" )
46
68
print ("creating script for entry point" , dist , group , name )
47
- with open (script_path , 'w' ) as fh :
69
+ with open (script_path , "w" ) as fh :
48
70
print ("import" , ep .module_name , file = fh )
49
- print ("%s.%s()" % (ep .module_name , '.' .join (ep .attrs )), file = fh )
71
+ print ("%s.%s()" % (ep .module_name , "." .join (ep .attrs )), file = fh )
50
72
for package in packages :
51
73
print ("import" , package , file = fh )
52
74
53
- return Analysis (
75
+ analysis = Analysis (
54
76
[script_path ] + scripts ,
55
77
pathex = pathex ,
56
78
hiddenimports = hiddenimports ,
57
79
hookspath = hookspath ,
58
80
excludes = excludes ,
59
81
runtime_hooks = runtime_hooks ,
60
- datas = datas
82
+ datas = datas ,
61
83
)
62
-
63
-
64
- if hasattr (pdb , 'pdb' ):
84
+ # `Analysis.binaries` behaves set-like and matches on the first tuple item (`name`).
85
+ # Since library names include the version we first build a list of the concrete names
86
+ # by prefix matching and then subtract that via the set-like behaviour.
87
+ binaries_to_remove = [
88
+ (name , None , None )
89
+ for name , * _ in analysis .binaries
90
+ if any (name .startswith (blocklist_item ) for blocklist_item in BINARIES_PREFIX_BLOCKLIST )
91
+ ]
92
+ analysis .binaries -= binaries_to_remove
93
+ return analysis
94
+
95
+
96
+ if hasattr (pdb , "pdb" ):
65
97
# pdbpp moves the stdlib pdb to the `pdb` attribute of it's own patched pdb module
66
98
raise RuntimeError (
67
- ' pdbpp is installed which causes broken PyInstaller builds. Please uninstall it.' ,
99
+ " pdbpp is installed which causes broken PyInstaller builds. Please uninstall it." ,
68
100
)
69
101
70
102
71
103
# We don't need Tk and friends
72
- sys .modules [' FixTk' ] = None
104
+ sys .modules [" FixTk" ] = None
73
105
74
- executable_name = ' raiden-{}-{}-{}' .format (
75
- os .environ .get (' ARCHIVE_TAG' , 'v' + get_system_spec ()[' raiden' ]),
76
- ' macOS' if platform .system () == ' Darwin' else platform .system ().lower (),
77
- platform .machine ()
106
+ executable_name = " raiden-{}-{}-{}" .format (
107
+ os .environ .get (" ARCHIVE_TAG" , "v" + get_system_spec ()[" raiden" ]),
108
+ " macOS" if platform .system () == " Darwin" else platform .system ().lower (),
109
+ platform .machine (),
78
110
)
79
111
80
112
a = Entrypoint (
81
- ' raiden' ,
82
- ' console_scripts' ,
83
- ' raiden' ,
84
- hookspath = [' tools/pyinstaller_hooks' ],
113
+ " raiden" ,
114
+ " console_scripts" ,
115
+ " raiden" ,
116
+ hookspath = [" tools/pyinstaller_hooks" ],
85
117
runtime_hooks = [
86
- ' tools/pyinstaller_hooks/runtime_gevent_monkey.py' ,
87
- ' tools/pyinstaller_hooks/runtime_encoding.py' ,
88
- ' tools/pyinstaller_hooks/runtime_raiden_contracts.py' ,
118
+ " tools/pyinstaller_hooks/runtime_gevent_monkey.py" ,
119
+ " tools/pyinstaller_hooks/runtime_encoding.py" ,
120
+ " tools/pyinstaller_hooks/runtime_raiden_contracts.py" ,
89
121
],
90
- hiddenimports = ['scrypt' , 'eth_tester' ],
122
+ hiddenimports = [],
91
123
datas = [],
92
- excludes = ['FixTk' , 'tcl' , 'tk' , '_tkinter' , 'tkinter' , 'Tkinter' ],
124
+ excludes = [
125
+ "_tkinter" ,
126
+ "FixTk" ,
127
+ "ipython" ,
128
+ "jupyter" ,
129
+ "jupyter_core" ,
130
+ "notebook" ,
131
+ "tcl" ,
132
+ "tk" ,
133
+ "tkinter" ,
134
+ "Tkinter" ,
135
+ ],
93
136
)
94
137
95
138
pyz = PYZ (a .pure , a .zipped_data , cipher = None )
@@ -103,10 +146,10 @@ if ONEFILE:
103
146
a .datas ,
104
147
name = executable_name ,
105
148
debug = False ,
106
- strip = True ,
149
+ strip = False ,
107
150
upx = False ,
108
151
runtime_tmpdir = None ,
109
- console = True
152
+ console = True ,
110
153
)
111
154
else :
112
155
exe = EXE (
@@ -117,7 +160,7 @@ else:
117
160
debug = True ,
118
161
strip = False ,
119
162
upx = False ,
120
- console = True
163
+ console = True ,
121
164
)
122
165
coll = COLLECT (
123
166
exe ,
@@ -126,5 +169,5 @@ else:
126
169
a .datas ,
127
170
strip = False ,
128
171
upx = False ,
129
- name = ' raiden'
172
+ name = " raiden" ,
130
173
)
0 commit comments