Skip to content

Commit 9e32e8b

Browse files
committed
Add a bin/sgr executable and use that as the PyInstaller entry point.
1 parent 2ecb5be commit 9e32e8b

File tree

3 files changed

+18
-38
lines changed

3 files changed

+18
-38
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ jobs:
136136
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then export EXTENSION=".exe"; fi
137137
- export BINARY_OUTPUT=sgr-"$TRAVIS_OS_NAME"-"$TRAVIS_CPU_ARCH""$EXTENSION"
138138
- mv dist/sgr"$EXTENSION" dist/"$BINARY_OUTPUT"
139+
- ls -lah dist/"$BINARY_OUTPUT"
139140
before_deploy: &before_deploy
140141
- echo "before_deploy"
141142
deploy: &deploy
@@ -145,6 +146,7 @@ jobs:
145146
file: dist/${BINARY_OUTPUT}
146147
skip_cleanup: true
147148
draft: true
149+
overwrite: true
148150
on:
149151
repo: splitgraph/splitgraph
150152
tags: true

bin/sgr

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
3+
from splitgraph.commandline import cli
4+
5+
cli()

splitgraph.spec

+11-38
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,22 @@
22
# Running:
33
# * pyinstaller -F splitgraph.spec produces a single sgr binary in the dist/ folder
44
# with libc being the only dynamic dependency (python interpreter included)
5-
# * can also do poetry install && poetry run -F splitgraph.spec to build the binary inside of the poetry's venv.
5+
# * can also do poetry install && poetry run pyinstaller -F splitgraph.spec to build the binary inside of the poetry's venv.
66

77
block_cipher = None
88

9-
# per https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Setuptools-Entry-Point
10-
def Entrypoint(dist, group, name, **kwargs):
11-
import pkg_resources
12-
13-
# get toplevel packages of distribution from metadata
14-
def get_toplevel(dist):
15-
distribution = pkg_resources.get_distribution(dist)
16-
if distribution.has_metadata('top_level.txt'):
17-
return list(distribution.get_metadata('top_level.txt').split())
18-
else:
19-
return []
20-
21-
kwargs.setdefault('hiddenimports', [])
22-
packages = []
23-
for distribution in kwargs['hiddenimports']:
24-
packages += get_toplevel(distribution)
25-
26-
kwargs.setdefault('pathex', [])
27-
# get the entry point
28-
ep = pkg_resources.get_entry_info(dist, group, name)
29-
# insert path of the egg at the verify front of the search path
30-
kwargs['pathex'] = [ep.dist.location] + kwargs['pathex']
31-
# script name must not be a valid module name to avoid name clashes on import
32-
script_path = os.path.join(workpath, name + '-script.py')
33-
print("creating script for entry point", dist, group, name)
34-
with open(script_path, 'w') as fh:
35-
print("import", ep.module_name, file=fh)
36-
print("%s.%s()" % (ep.module_name, '.'.join(ep.attrs)), file=fh)
37-
for package in packages:
38-
print("import", package, file=fh)
9+
a = Analysis(['bin/sgr'],
10+
pathex=['.'],
11+
hiddenimports=[],
12+
# Disable ingestion extras for now (we're looking at replacing this
13+
# with something more lightweight)
14+
excludes=['pandas','numpy','scipy', 'sqlalchemy'],
15+
hookspath=[],
16+
runtime_hooks=[],
17+
cipher=block_cipher)
3918

40-
return Analysis(
41-
[script_path] + kwargs.get('scripts', []),
42-
**kwargs
43-
)
19+
a.datas += Tree('./splitgraph/resources', 'splitgraph/resources')
4420

45-
a = Entrypoint('splitgraph', 'console_scripts', 'sgr',
46-
datas=[('splitgraph/resources', 'splitgraph/resources')]) # Add the resources folder with the audit trigger
4721
pyz = PYZ(a.pure, a.zipped_data,
4822
cipher=block_cipher)
4923
exe = EXE(pyz,
@@ -59,4 +33,3 @@ exe = EXE(pyz,
5933
upx=True,
6034
runtime_tmpdir=None,
6135
console=True )
62-

0 commit comments

Comments
 (0)