pyinstaller build method

pyinstaller packages up all of a python script's dependencies and builds them
into standalone executables.  It can either do a directory (containing a
single executable and a bunch of shared libraries) or a self-contained
executable that effectively just contains a compressed version of the
directory.

The problem is, if you have several scripts like we do, you get several
large directories or standalone binaries, and there's a ton of duplication
between them.  Fortunately it looks like using the directory method and just
combining the directories works fine (for this project).
pull/16/head
Lex Neva 2018-01-08 21:33:35 -05:00
rodzic 530aba9d8d
commit 03bcf51219
3 zmienionych plików z 53 dodań i 1 usunięć

7
.gitignore vendored
Wyświetl plik

@ -1,2 +1,7 @@
.*.swp
*.pyc
*.pyc
*.spec
*.zip
*.tar.gz
dist/
build/

17
Makefile 100644
Wyświetl plik

@ -0,0 +1,17 @@
EXTENSIONS:=embroider embroider_params embroider_simulate embroider_update
VERSION:=$(shell git tag -l | grep ^v | tail -n 1)
TARBALL:=inkstitch-$(VERSION)-$(shell uname)-$(shell uname -m).tar.gz
dist: distclean
mkdir -p dist/inkstitch/bin
for extension in $(EXTENSIONS); do \
pyinstaller -p /usr/share/inkscape/extensions $${extension}.py; \
cp -a dist/$${extension}/* dist/inkstitch/bin; \
rm -rf dist/$${extension}; \
cp stub.py dist/$${extension}.py; \
done;
cp *.inx dist
cd dist; tar zcf ../$(TARBALL) *
distclean:
rm -rf build dist *.spec *.tar.gz

30
stub.py 100644
Wyświetl plik

@ -0,0 +1,30 @@
#!/usr/bin/env python
import sys
import os
# ink/stitch
#
# stub.py: pyinstaller execution stub
#
# pyinstaller packages the inkstitch extensions into nice tidy executables.
# That's great, but Inkscape can't execute a plain binary as an extension(!).
#
# This Python script exists only to execute the actual extension binary. It
# can be copied to, e.g., "embroider_params.py", in which case it will look
# for a binary at inkstitch/bin/embroider_params.
script_name = os.path.basename(__file__)
if script_name.endswith('.py'):
binary_name = script_name[:-3]
else:
# Probably not right, but we can at least try.
binary_name = script_name
binary_path = os.path.join("inkstitch", "bin", binary_name)
args = sys.argv[:]
args[0] = binary_path
os.execv(binary_path, args)