summaryrefslogtreecommitdiff
path: root/bin/build-python
blob: 5d16cdf836919bffd3619309fc3331dc3d885eda (plain)
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
#!/bin/bash

set -e

site_packages="$(python -c "import os; print(os.path.dirname(os.__file__) + '/site-packages')")"

if [ "$BUILD" = "linux" ]; then
    # pyinstaller misses these
    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:. "
    pyinstaller_args+="--add-binary  /lib/x86_64-linux-gnu/libnsl.so.1:. "
    pyinstaller_args+="--add-binary  /usr/lib/x86_64-linux-gnu/libxcb.so.1:. "
fi

# 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 "

# mac and windows build seem to miss wx import
pyinstaller_args+="--hidden-import wx "

# We need to use the precompiled bootloader linked with graphical Mac OS X
# libraries if we develop a GUI application for Mac:
if [ "$BUILD" = "osx" -o "$BUILD" = "windows" ]; then
    pyinstaller_args+="--windowed "
fi

# This lets pyinstaller see inkex.py, etc.
pyinstaller_args+="-p inkscape/share/extensions "

# output useful debugging info that helps us trace library dependency issues
pyinstaller_args+="--log-level DEBUG "

# This adds bundle identifier in reverse DSN format for macos
if [ "$BUILD" = "osx" ]; then
    pyinstaller_args+="--osx-bundle-identifier org.inkstitch.app "
    if [[ -z ${GITHUB_REF} ]]; then
        :
    else
        bash bin/import-macos-keys
    fi
fi

if [ "$BUILD" = "windows" ]; then
    python -m PyInstaller $pyinstaller_args inkstitch.py
else
    # without the LD_LIBRARY_PATH, it seems that pyinstaller can't find all of
    # wxpython's shared libraries
    LD_LIBRARY_PATH="${site_packages}/wx" python -m PyInstaller $pyinstaller_args --strip inkstitch.py;
fi

# pyinstaller put a whole mess of libraries under dist/inkstitch.  We'd like
# to put some more user-accessible stuff like examples and palettes in
# folders under inkstitch/ (see ../Makefile) so let's move the pyinstaller
# stuff into its own dir.
shopt -s dotglob
mkdir dist/bin
mv dist/inkstitch/* dist/bin
mv dist/bin dist/inkstitch