Skip to content

Commit 8f1d00a

Browse files
committed
Add pyinstaller spec
1 parent d7565fd commit 8f1d00a

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ MANIFEST
2929
# Usually these files are written by a python script from a template
3030
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3131
*.manifest
32-
*.spec
32+
# *.spec
3333

3434
# Installer logs
3535
pip-log.txt

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"python.unitTest.unittestEnabled": true,
33
"python.unitTest.pyTestEnabled": true,
4+
"files.associations": {
5+
"*.spec": "python",
6+
},
47
}

pyinstaller.spec

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- mode: python -*-
2+
3+
import platform
4+
5+
block_cipher = None
6+
7+
8+
def Entrypoint(dist, group, name, **kwargs):
9+
import pkg_resources
10+
11+
# get toplevel packages of distribution from metadata
12+
def get_toplevel(dist):
13+
distribution = pkg_resources.get_distribution(dist)
14+
if distribution.has_metadata('top_level.txt'):
15+
return list(distribution.get_metadata('top_level.txt').split())
16+
else:
17+
return []
18+
19+
kwargs.setdefault('hiddenimports', [])
20+
packages = []
21+
for distribution in kwargs['hiddenimports']:
22+
packages += get_toplevel(distribution)
23+
24+
kwargs.setdefault('pathex', [])
25+
# get the entry point
26+
ep = pkg_resources.get_entry_info(dist, group, name)
27+
# insert path of the egg at the verify front of the search path
28+
kwargs['pathex'] = [ep.dist.location] + kwargs['pathex']
29+
# script name must not be a valid module name to avoid name clashes on import
30+
script_path = os.path.join(workpath, name + '-script.py')
31+
print("creating script for entry point", dist, group, name)
32+
with open(script_path, 'w') as fh:
33+
print("import", ep.module_name, file=fh)
34+
print("%s.%s()" % (ep.module_name, '.'.join(ep.attrs)), file=fh)
35+
for package in packages:
36+
print("import", package, file=fh)
37+
38+
return Analysis(
39+
[script_path] + kwargs.get('scripts', []),
40+
**kwargs
41+
)
42+
43+
44+
a = Entrypoint('iotedgehubdev', 'console_scripts', 'iotedgehubdev')
45+
46+
pyz = PYZ(a.pure, a.zipped_data,
47+
cipher=block_cipher)
48+
49+
# exe = EXE(pyz,
50+
# a.scripts,
51+
# [],
52+
# exclude_binaries=True,
53+
# name='setup',
54+
# debug=False,
55+
# bootloader_ignore_signals=False,
56+
# strip=False,
57+
# upx=True,
58+
# console=True )
59+
# coll = COLLECT(exe,
60+
# a.binaries,
61+
# a.zipfiles,
62+
# a.datas,
63+
# strip=False,
64+
# upx=True,
65+
# name='setup')
66+
67+
exe = EXE(pyz,
68+
a.scripts,
69+
a.binaries,
70+
a.zipfiles,
71+
a.datas,
72+
name='iotedgehubdev-{0}-X86_64'.format(platform.system()),
73+
debug=False,
74+
strip=False,
75+
upx=True,
76+
runtime_tmpdir=None,
77+
console=True)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ prompt_toolkit
1111
rope
1212
tox
1313
pyyaml
14-
jsonpath_rw
14+
jsonpath_rw
15+
pyinstaller

0 commit comments

Comments
 (0)