-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.spec
67 lines (58 loc) · 1.89 KB
/
main.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
# -*- mode: python -*-
import os
block_cipher = None
def Entrypoint(dist, group, name,
scripts=None, pathex=None, hiddenimports=None,
hookspath=None, excludes=None, runtime_hooks=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:
packages += get_toplevel(distribution)
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)
return Analysis(
[script_path] + scripts,
pathex,
hiddenimports,
hookspath,
excludes,
runtime_hooks
)
a = Entrypoint('ssl_exporter',
'console_scripts',
'ssl_exporter'
)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='ssl-exporter',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )