summaryrefslogtreecommitdiff
path: root/bin/build-dist
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-01-13 20:18:50 -0500
committerGitHub <noreply@github.com>2018-01-13 20:18:50 -0500
commit8bab858be6699bf393694dfe05c2c49f01e5c27a (patch)
tree8b51736007099318b80170148a36e5c98c5f80fd /bin/build-dist
parentf244f58a17c2a35a499424da4935c12b0385715b (diff)
pyinstaller release method (#16)
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). This PR runs the above build on any tagged commit and publishes a release in github containing the pyinstall-ified tarball. If the tag is named like "v1.2.3" _and_ the tag is on the master branch, then the github release will be marked as "production". Otherwise, it will be marked as a "pre-release". This means that we can build testable tarballs of the extension in a pull request by tagging a commit.
Diffstat (limited to 'bin/build-dist')
-rwxr-xr-xbin/build-dist39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/build-dist b/bin/build-dist
new file mode 100755
index 00000000..f3090178
--- /dev/null
+++ b/bin/build-dist
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+site_packages="$(python -c "import os; print(os.path.dirname(os.__file__) + '/site-packages')")"
+
+# pyinstaller misses these two
+pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so:. "
+pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/libproxy.so.1:. "
+
+# This one's tricky. ink/stitch doesn't actually _use_ gi.repository.Gtk,
+# but it does use GTK (through wxPython). pyinstaller has some special
+# logic to handle GTK apps that is engaged when you import
+# gi.repository.Gtk that pulls in things like themes, icons, etc. Without
+# that, the Params dialog is unthemed and barely usable. This hidden
+# import option is actually the only reason we had to install python-gi
+# above!
+pyinstaller_args+="--hidden-import gi.repository.Gtk "
+
+# This lets pyinstaller see inkex.py, etc.
+pyinstaller_args+="-p /usr/share/inkscape/extensions "
+
+mkdir -p dist/inkstitch/bin
+for extension in "$@"; do
+ # without the LD_LIBRARY_PATH, it seems that pyinstaller can't find all of
+ # wxpython's shared libraries
+ LD_LIBRARY_PATH="${site_packages}/wx" pyinstaller $pyinstaller_args ${extension}.py;
+
+ # By default, pyinstaller will treat each of ink/stitch's extensions
+ # separately. This means it packages a lot of the same shared libraries (like
+ # wxPython) multiple times. Turns out that we can just copy the contents of
+ # the directories pyinstaller creates into one and it works fine, eliminating
+ # the duplication. This significantly decreases the size of the inkstitch
+ # tarball/zip.
+ cp -a dist/${extension}/* dist/inkstitch/bin
+ rm -rf dist/${extension}
+
+ # Inkscape doesn't let us run native binaries as extensions(?!). Instead we
+ # add this stub script which executes the binaries that pyinstaller creates.
+ cp stub.py dist/${extension}.py
+done