Change to a binary launcher in Mac app bundles.

This commit is contained in:
John Ralls 2016-08-13 15:50:39 -07:00
parent 3e323e496f
commit 13c95d00d7
4 changed files with 63 additions and 58 deletions

View File

@ -26,5 +26,7 @@
<string>Copyright 1997 - 2016 The Gramps Team, GNU General Public License.</string>
<key>LSMinimumSystemVersion</key>
<string>10.5</string>
<key>GtkOSXLaunchScriptFile</key>
<string>gramps_launcher.py</string>
</dict>
</plist>

View File

@ -5,23 +5,23 @@
<prefix name="default">${env:JHBUILD_PREFIX}</prefix>
<destination overwrite="yes">${env:HOME}/Desktop</destination>
<run-install-name-tool/>
<launcher-script>${project}/gramps.launcher</launcher-script >
<!-- Indicate the active gtk version to use. This is needed only
for gtk+-3.0 projects. -->
<gtk>gtk+-3.0</gtk>
</meta>
<plist>${project}/Info.plist</plist>
<!-- We have to have this, but the result is ignored. -->
<!-- Build gramps-launcher with:
gcc -L$PREFIX `python-config --cflags --ldflags` \
-o $PREFIX/bin/gramps-launcher \
path/to/gtk-mac-bundler/examples/python-launcher.c
with the obvious substitution.
-->
<main-binary>
${prefix}/bin/gramps
${prefix}/bin/gramps-launcher
</main-binary>
<!-- We need to pack our own Python to avoid compatibility problems. -->
<binary dest="${bundle}/Contents/MacOS">
${prefix}/bin/python
</binary>
<!-- Copy in GTK+ modules. Note the use of the
"${pkg:module:variable}" macro, which evaluates to a pkg-config
variable in the specified module. Note that any libraries that
@ -128,6 +128,10 @@
${prefix}/share/locale
</translations>
<!-- Our launcher script isn't a shell script any more, and our binary really is a binary. -->
<data dest="${bundle}/Contents/Resources">
${project}/gramps_launcher.py
</data>
<!-- We have to pull in the python modules, which are mixed python
and loadable modules. -->

View File

@ -1,50 +0,0 @@
#!/bin/sh
name="`basename $0`"
tmp="$0"
tmp=`dirname "$tmp"`
tmp=`dirname "$tmp"`
bundle=`dirname "$tmp"`
bundle_contents="$bundle"/Contents
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib
bundle_bin="$bundle_res"/bin
bundle_data="$bundle_res"/share
bundle_etc="$bundle_res"/etc
export XDG_DATA_DIRS="$bundle_data"
export PATH="$bundle_contents"/MacOS:/bin:/usr/bin
export DYLD_LIBRARY_PATH="$bundle_lib"
export LD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"
export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
export PANGO_SYSCONFDIR="$bundle_etc"
export PANGO_LIBDIR="$bundle_lib"
export GDK_PIXBUF_MODULE_FILE="$bundle_lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
if [ `uname -r | cut -d . -f 1` -ge 10 ]; then
export GTK_IM_MODULE_FILE="$bundle_etc/gtk-3.0/gtk.immodules"
fi
export GI_TYPELIB_PATH="$bundle_lib/girepository-1.0"
export GVBINDIR="$bundle_lib/graphviz"
export ENCHANT_MODULE_PATH="$bundle_lib/enchant"
#Set $PYTHON to point inside the bundle
PYVER=3.4
export PYTHON="$bundle_contents/MacOS/python"
export PYTHONHOME="$bundle_res"
export GRAMPSDIR="$bundle_lib/python$PYVER/site-packages/gramps"
export GRAMPSI18N="$bundle_data"/locale
export GRAMPS_RESOURCES="$bundle_data"
export USERPROFILE="$HOME"
export APPDATA="$HOME/Library/Application Support"
# Strip out the argument added by the OS.
if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
shift 1
fi
exec "$PYTHON" -O "$bundle_contents/MacOS/Gramps-bin" "$@"

49
mac/gramps_launcher.py Normal file
View File

@ -0,0 +1,49 @@
from os.path import join, dirname, abspath, normpath
from os import environ
from sys import argv, version
from platform import release
bundlepath = argv[0]
bundle_contents = join(bundlepath, 'Contents')
bundle_res = join(bundle_contents, 'Resources')
bundle_lib = join(bundle_res, 'lib')
bundle_bin = join(bundle_res, 'bin')
bundle_data = join(bundle_res, 'share')
bundle_etc = join(bundle_res, 'etc')
environ['XDG_DATA_DIRS'] = bundle_data
environ['DYLD_LIBRARY_PATH'] = bundle_lib
environ['LD_LIBRARY_PATH'] = bundle_lib
environ['GTK_DATA_PREFIX'] = bundle_res
environ['GTK_EXE_PREFIX'] = bundle_res
environ['GTK_PATH'] = bundle_res
environ['PANGO_RC_FILE'] = join(bundle_etc, 'pango', 'pangorc')
environ['PANGO_SYSCONFDIR'] = bundle_etc
environ['PANGO_LIBDIR'] = bundle_lib
environ['GDK_PIXBUF_MODULE_FILE'] = join(bundle_lib, 'gdk-pixbuf-2.0',
'2.10.0', 'loaders.cache')
if int(release().split('.')[0]) > 10:
environ['GTK_IM_MODULE_FILE'] = join(bundle_etc, 'gtk-3.0',
'gtk.immodules')
environ['GI_TYPELIB_PATH'] = join(bundle_lib, 'girepository-1.0')
environ['GVBINDIR'] = join(bundle_lib, 'graphviz')
environ['ENCHANT_MODULE_PATH'] = join(bundle_lib, 'enchant')
#Set $PYTHON to point inside the bundle
PYVER = 'python' + version[:3]
environ['GRAMPSDIR'] = join (bundle_lib, PYVER, 'site-packages', 'gramps')
environ['GRAMPSI18N'] = join(bundle_data, 'locale')
environ['GRAMPS_RESOURCES'] = bundle_data
environ['USERPROFILE'] = environ['HOME']
environ['APPDATA'] = join(environ['HOME'], 'Library', 'Application Support')
environ['PATH'] = join(bundle_contents, 'MacOS') + ':' + environ['PATH']
import gramps.grampsapp as app
app.main()