forked from leo-editor/leo-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchLeo-unified.spec
409 lines (394 loc) · 17.9 KB
/
launchLeo-unified.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
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#@+leo-ver=5-thin
#@+node:ekr.20160124165611.1: * @file ../../launchLeo-unified.spec
#@@language python
# -*- mode: python -*-
'''
launchLeo-unified.spec
a pyinstaller .spec file that creates a stand-alone version of Leo.
This is a single .exe file or a folder, depending on generate_folder.
>pyinstaller launchLeo-unified.spec
This may be better, per: https://stackoverflow.com/questions/32457341
>pyinstaller --clean --win-private-assemblies launchLeo-unified.spec
'''
# Requires setuptools 19.2 (19.4 is broken)
# https://github.com/pyinstaller/pyinstaller/issues/1781
generate_folder = True
# True is *highly* recommended.
#@+<< imports >>
#@+node:edward.20160313203026.1: ** << imports >> launchLeo-unified.spec
import glob
import os
import sys
is_mac = sys.platform.startswith('darwin')
# Same code as in runLeo.py.
path = os.getcwd()
if path not in sys.path:
print('launchLeo-unified.spec: appending %s to sys.path' % path)
sys.path.append(path)
import leo.core.leoGlobals as g
import leo.core.leoApp as leoApp
LM = leoApp.LoadManager()
loadDir = LM.computeLoadDir()
#@-<< imports >>
#@+others
#@+node:edward.20160313203148.2: ** all, ext, icons
# Utilities for creating entries in the "datas" lists...
def all(name):
'''Return a tuple that causes all files in name to be included.'''
return ('%s/*.*' % (name), name)
icons = all
def ext(kind, name):
'''
Return a tuple that causes all files with the given extension in name
to be included.
'''
if kind.startswith('.'):
kind = kind[1:]
return ('%s/*.%s' % (name, kind), name)
#@+node:edward.20160313203912.1: ** define_added_binaries
def define_added_binaries():
'''Return the added binaries needed for MacOS.'''
if is_mac and False:
# This doesn't work, and produces huge folders.
lib_root = os.path.expanduser(
'~/anaconda2/pkgs/qt-4.8.7-1/lib')
assert os.path.exists(lib_root), lib_root
qt_root = os.path.expanduser(
'~/anaconda2/lib/python2.7/site-packages/PyQt4')
assert os.path.exists(qt_root), qt_root
prefix = 'PyQt4' # None means top-level folder.
return (
Tree(
lib_root,
prefix=prefix,
excludes=['pkgconfig','*.a',],
) +
Tree(
qt_root,
prefix=prefix,
excludes=[]
)
)
return []
#@+node:edward.20160313203338.1: ** define_datas
def define_datas():
'''Return all needed data files.'''
return [
# Required for startup...
('leo/core/commit_timestamp.json', 'leo/core'),
ext('.ui', 'leo/plugins'),
# Required for plugins...
# Data requifed for startup.
all('leo/plugins/GraphCanvas'),
# These are also hidden imports...
ext('.py', 'leo/plugins'),
ext('.py', 'leo/plugins/importers'),
ext('.py', 'leo/plugins/writers'),
# leo/config...
ext('.leo', 'leo/config'),
# leo/modes...
ext('.py', 'leo/modes'),
ext('.xml', 'leo/modes'),
# All icons...
# This list created by print_icon_directories.
icons('leo/Icons'),
icons('leo/Icons/Tango/16x16/actions'),
icons('leo/Icons/Tango/16x16/animations'),
icons('leo/Icons/Tango/16x16/apps'),
icons('leo/Icons/Tango/16x16/categories'),
icons('leo/Icons/Tango/16x16/devices'),
icons('leo/Icons/Tango/16x16/emblems'),
icons('leo/Icons/Tango/16x16/emotes'),
icons('leo/Icons/Tango/16x16/mimetypes'),
icons('leo/Icons/Tango/16x16/places'),
icons('leo/Icons/Tango/16x16/status'),
icons('leo/Icons/cleo'),
icons('leo/Icons/cleo/small'),
icons('leo/Icons/file_icons'),
icons('leo/Icons/nodes-dark/plusminus'),
icons('leo/Icons/nodes-dark/triangles'),
icons('leo/Icons/nodes-light/plusminus'),
icons('leo/Icons/nodes-light/triangles'),
icons('leo/Icons/recorder'),
icons('leo/Icons/transparent/boxes/black'),
icons('leo/Icons/transparent/boxes/solarized'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base0'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base00'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base01'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base02'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base03'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base1'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base2'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/base3'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/black1'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/black2'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/blue'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/cyan'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/green'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/magenta'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/orange'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/red'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/violet'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/white'),
icons('leo/Icons/transparent/boxes/solarized-monochromatic/yellow'),
icons('leo/Icons/transparent/boxes/white'),
icons('leo/Icons/transparent/icons/declutter/directives/black'),
icons('leo/Icons/transparent/icons/declutter/directives/solarized'),
icons('leo/Icons/transparent/icons/declutter/directives/solarized-monochromatic'),
icons('leo/Icons/transparent/icons/declutter/directives/white'),
icons('leo/Icons/transparent/icons/declutter/file/black/empty'),
icons('leo/Icons/transparent/icons/declutter/file/black/text'),
icons('leo/Icons/transparent/icons/declutter/file/solarized-monochromatic/empty'),
icons('leo/Icons/transparent/icons/declutter/file/solarized-monochromatic/text'),
icons('leo/Icons/transparent/icons/declutter/file/solarized/empty/outlined'),
icons('leo/Icons/transparent/icons/declutter/file/solarized/empty/solid'),
icons('leo/Icons/transparent/icons/declutter/file/solarized/text/outlined'),
icons('leo/Icons/transparent/icons/declutter/file/solarized/text/solid'),
icons('leo/Icons/transparent/icons/declutter/file/white/empty'),
icons('leo/Icons/transparent/icons/declutter/file/white/text'),
icons('leo/Icons/transparent/icons/declutter/folder/black'),
icons('leo/Icons/transparent/icons/declutter/folder/black/horizontal'),
icons('leo/Icons/transparent/icons/declutter/folder/black/path'),
icons('leo/Icons/transparent/icons/declutter/folder/black/vertical'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized-monochromatic'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized-monochromatic/horizontal'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized-monochromatic/path'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized-monochromatic/vertical'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/horizontal/outlined'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/horizontal/solid'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/path/outlined'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/path/solid'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/vertical/outlined'),
icons('leo/Icons/transparent/icons/declutter/folder/solarized/vertical/solid'),
icons('leo/Icons/transparent/icons/declutter/folder/white'),
icons('leo/Icons/transparent/icons/declutter/folder/white/horizontal'),
icons('leo/Icons/transparent/icons/declutter/folder/white/path'),
icons('leo/Icons/transparent/icons/declutter/folder/white/vertical'),
icons('leo/Icons/transparent/icons/misc/black'),
icons('leo/Icons/transparent/icons/misc/solarized'),
icons('leo/Icons/transparent/icons/misc/solarized-monochromatic'),
icons('leo/Icons/transparent/icons/misc/white'),
icons('leo/Icons/transparent/icons/nodes/plusminus/black'),
icons('leo/Icons/transparent/icons/nodes/plusminus/solarized'),
icons('leo/Icons/transparent/icons/nodes/plusminus/white'),
icons('leo/Icons/transparent/icons/nodes/triangles/black'),
icons('leo/Icons/transparent/icons/nodes/triangles/solarized'),
icons('leo/Icons/transparent/icons/nodes/triangles/white'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base0'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base00'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base01'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base02'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base03'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base1'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base2'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/base3'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/black1'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/black2'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/blue'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/cyan'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/green'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/magenta'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/orange'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/red'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/violet'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/white'),
icons('leo/Icons/transparent/icons/task/solarized/monochromatic/yellow'),
icons('leo/Icons/transparent/icons/task/solarized/regular'),
icons('leo/Icons/transparent/icons/task/solarized/small'),
icons('leo/Icons/transparent/icons/toolbar/black'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base0'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base00'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base01'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base02'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base03'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base1'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base2'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/base3'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/black1'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/black2'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/blue'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/cyan'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/green'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/magenta'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/orange'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/red'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/violet'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/white'),
icons('leo/Icons/transparent/icons/toolbar/solarized-monochromatic/yellow'),
icons('leo/Icons/transparent/icons/toolbar/white'),
# The following files *are* useful in one-file operation.
# sys._MEIPASS points to the temp folder.
# On windows: ~\AppData\Local\Temp\_MEInnnn
# leo-editor: loaded by LeoPy.leo...
('launchLeo-unified.spec', ''),
('leo_to_html.xsl', ''),
('pylint-leo.py', ''),
# In LeoPyRef.leo...
('flake8-leo.py', ''),
('load-leo.html', ''),
('pyflakes-leo.py', ''),
# ('setup.py', ''),
# leo.commands...
ext('.py', 'leo/commands'),
# leo.core...
# Only include reference files.
# ext('.leo', 'leo/core'),
('leo/core/LeoPyRef.leo', 'leo/core'),
ext('.py', 'leo/core'),
ext('.txt', 'leo/core'),
# leo.dist...
all('leo/dist'),
# leo/doc & leo/doc/html
ext('.css', 'leo/doc'),
ext('.js', 'leo/doc'),
ext('.html', 'leo/doc'),
ext('.md', 'leo/doc'),
ext('.leo', 'leo/doc'),
ext('.py', 'leo/doc'),
ext('.txt', 'leo/doc'),
all('leo/doc/html'),
# ext('.jif','leo/doc/html'),
# ext('.py','leo/doc/html'),
# ext('.txt','leo/doc/html'),
# leo/extensions...
ext('.py', 'leo/extensions'),
all('leo/extensions/hooks'),
# leo/external...
ext('.cfg', 'leo/external'),
ext('.md', 'leo/external'),
ext('.leo', 'leo/external'),
ext('.py', 'leo/external'),
ext('.txt', 'leo/external'),
ext('.css', 'leo/external/ckeditor'),
ext('.js', 'leo/external/ckeditor'),
ext('.json', 'leo/external/ckeditor'),
ext('.md', 'leo/external/ckeditor'),
# leo/plugins...
# Only include reference files.
# ext('.leo', 'leo/plugins'),
('leo/plugins/leoPluginsRef.leo', 'leo/plugins'),
('leo/plugins/leoGuiPluginsRef.leo', 'leo/plugins'),
ext('.txt', 'leo/plugins'),
ext('.py', 'leo/plugins/examples'),
ext('.py', 'leo/plugins/test'),
# leo/scripts...
ext('.bat', 'leo/scripts'),
ext('.leo', 'leo/scripts'),
ext('.txt', 'leo/scripts'),
ext('.py', 'leo/scripts'),
# Everything required for unit tests...
# execute-script requires the leo/test folder itself.
ext('.leo', 'leo/test'),
ext('.py', 'leo/test'),
ext('.txt', 'leo/test'),
ext('.css', 'leo/test'),
all('leo/test/unittest'),
all('leo/test/unittest/input'),
all('leo/test/unittest/output'),
all('leo/test/unittest/perfectImport'),
# leo/www...
all('leo/www'),
]
#@+node:edward.20160313203420.1: ** define_hidden_imports
def define_hidden_imports():
'''Define all modules in leo.plugins & leo.modes.'''
hidden_imports = []
for name in ('external', 'modes', 'plugins',
'plugins/importers', 'plugins/writers',
):
hidden_imports.extend(get_modules(name))
hidden_imports = [z.replace('/','.') for z in hidden_imports]
if 0:
print('hidden imports...')
for z in sorted(hidden_imports):
print(z)
sys.exit()
return hidden_imports
#@+node:edward.20160313203148.1: ** get_modules
def get_modules(name):
'''
Return a list of module names (separated by dots) in the leo/x directory.
This could be replaced by PyInstaller.utils.hooks.collect_submodules.
'''
abs_dir = g.os_path_finalize_join(loadDir, '..', name)
n = len(abs_dir) + 1
aList = glob.glob(abs_dir + '/*.py')
return ['leo.%s.%s' % (name, z[n:][: -3]) for z in aList]
#@+node:edward.20160313203251.1: ** main
def main():
'''Main line of launchLeo-unified.spec.'''
added_binaries = define_added_binaries()
datas = define_datas()
hidden_imports = define_hidden_imports()
exclude_modules = ['_tkinter',]
a = Analysis(['launchLeo.py'],
pathex=[],
binaries=None,
datas=datas,
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
excludes=exclude_modules,
win_no_prefer_redirects=None,
win_private_assemblies=None,
cipher=None)
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
if generate_folder:
if is_mac:
# Does not work at present.
exe = EXE(pyz,
a.scripts,
a.binaries + added_binaries,
exclude_binaries=False,
name='LeoApp', # 'leo' doesn't work on Linux.
debug=False,
strip=None,
upx=True,
console=True )
else:
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='LeoApp', # 'leo' doesn't work on Linux.
debug=False,
strip=None,
upx=True,
console=True )
else:
exe = EXE(pyz,
a.scripts,
a.binaries + added_binaries,
a.zipfiles,
a.datas,
name='LeoApp', # 'leo' doesn't work on Linux.
debug=False,
strip=None,
upx=True,
console=True)
if generate_folder:
coll = COLLECT(
exe,
a.binaries + added_binaries,
a.zipfiles,
a.datas,
strip=None,
upx=False,
name='LeoAppFolder')
#@+node:ekr.20170316215354.1: ** print_icon_directories
def print_icon_directories():
'''Print list of all Icon directories containing icons.'''
g.cls()
import os
rootDir = g.os_path_finalize_join(g.app.loadDir, '..', 'Icons')
result = []
for dirName, subdirList, fileList in os.walk(rootDir):
if fileList:
s = dirName.replace('\\','/')
s = s.replace('C:/leo.repo/leo-editor/','')
result.append("icons('%s')," % (s))
for path in sorted(result):
print(path)
#@-others
main()
#@-leo