From 350ef993e59b3ede7dd621a81f096ea78296c5c8 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sun, 24 Sep 2017 11:54:55 +0200 Subject: [PATCH] add inkscape wrapper script for Mac OS The wrapper script is placed in the binary directory of the LyX bundle. It tries to find the real inkscape command line converter in the Inkscape.app bundle and starts it or reports an error. The configure.py is changed for Mac OS to check the presence of the real inkscape binary in the Inkscape.app bundle. --- development/MacOSX/Makefile.am | 2 +- development/MacOSX/inkscape | 15 +++++++++++++++ lib/configure.py | 27 ++++++++++++++++++--------- 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100755 development/MacOSX/inkscape diff --git a/development/MacOSX/Makefile.am b/development/MacOSX/Makefile.am index b9cdfa6575..9ca0c22a5f 100644 --- a/development/MacOSX/Makefile.am +++ b/development/MacOSX/Makefile.am @@ -8,7 +8,7 @@ bundledir = ${prefix}/Contents dist_bundle_DATA = PkgInfo nodist_bundle_DATA = Info.plist -dist_bin_SCRIPTS = lyxeditor maxima +dist_bin_SCRIPTS = lyxeditor maxima inkscape dist_pkgdata_DATA = COPYING LyXapp.icns LyX.icns LyX.sdef dmg-background.png nodist_pkgdata_DATA = lyxrc.dist diff --git a/development/MacOSX/inkscape b/development/MacOSX/inkscape new file mode 100755 index 0000000000..bc34e86ddb --- /dev/null +++ b/development/MacOSX/inkscape @@ -0,0 +1,15 @@ +#!/bin/bash +unset DISPLAY +# at first try the well known location +RESDIR="/Applications/Inkscape.app/Contents/Resources" +test -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape && exec "${RESDIR}"/bin/inkscape --without-gui "$@" +# this failed... so try PATH expansion to start the inkscape shell wrapper +IFS=":" read -ra DIRLIST <<< "${PATH}" +for BINDIR in "${DIRLIST[@]}" ; do + RESDIR=$(dirname "${BINDIR}") + test -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape && exec "${RESDIR}"/bin/inkscape --without-gui "$@" +done +# report error and exit with failure status +exec 1>&2 +echo Could not find Inkscape binary. +exit 1 diff --git a/lib/configure.py b/lib/configure.py index a6740327ca..e9b789085e 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -494,7 +494,16 @@ def checkDTLtools(): def checkInkscape(): ''' Check whether Inkscape is available and return the full path (Windows only) ''' - if os.name != 'nt': + ''' On Mac OS (darwin) a wrapper is used - therefore the version is checked ''' + ''' The answer of the real inkscape is validated and a fake binary used if this fails ''' + if sys.platform == 'darwin': + version_string = cmdOutput("inkscape --version") + match = re.match('^Inkscape', version_string) + if match: + return 'inkscape' + else: + return 'inkscape-binary' + elif os.name != 'nt': return 'inkscape' if sys.version_info[0] < 3: import _winreg as winreg @@ -981,11 +990,11 @@ def checkConverterEntries(): \converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" ""''') # checkProg('a SVG -> PDFTeX converter', [inkscape_name], - rc_entry = [ r'\converter svg pdftex "python -tt $$s/scripts/svg2pdftex.py %% $$i $$o" ""'], + rc_entry = [ r'\converter svg pdftex "python -tt $$s/scripts/svg2pdftex.py %% $$p$$i $$p$$o" ""'], path = [inkscape_path]) # checkProg('a SVG -> PSTeX converter', [inkscape_name], - rc_entry = [ r'\converter svg pstex "python -tt $$s/scripts/svg2pstex.py %% $$i $$o" ""'], + rc_entry = [ r'\converter svg pstex "python -tt $$s/scripts/svg2pstex.py %% $$p$$i $$p$$o" ""'], path = [inkscape_path]) # checkProg('a TIFF -> PS converter', ['tiff2ps $$i > $$o'], @@ -997,16 +1006,16 @@ def checkConverterEntries(): \converter tgif png "tgif -print -color -png -o $$d $$i" "" \converter tgif pdf6 "tgif -print -color -pdf -stdout $$i > $$o" ""''']) # - checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'], + checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-eps=$$p$$o'], rc_entry = [ r'\converter wmf eps "%%" ""']) # - checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'], + checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-eps=$$p$$o'], rc_entry = [ r'\converter emf eps "%%" ""']) # - checkProg('a WMF -> PDF converter', [inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'], + checkProg('a WMF -> PDF converter', [inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-pdf=$$p$$o'], rc_entry = [ r'\converter wmf pdf6 "%%" ""']) # - checkProg('an EMF -> PDF converter', [inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'], + checkProg('an EMF -> PDF converter', [inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-pdf=$$p$$o'], rc_entry = [ r'\converter emf pdf6 "%%" ""']) # Only define a converter to pdf6 for graphics checkProg('an EPS -> PDF converter', ['epstopdf'], @@ -1052,12 +1061,12 @@ def checkConverterEntries(): rc_entry = [ r'\converter svg svgz "%%" ""']) # Only define a converter to pdf6 for graphics # Prefer rsvg-convert over inkscape since it is faster (see http://www.lyx.org/trac/ticket/9891) - checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'], + checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-pdf=$$p$$o'], rc_entry = [ r'''\converter svg pdf6 "%%" "" \converter svgz pdf6 "%%" ""'''], path = ['', inkscape_path]) # - checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_name + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'], + checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_name + ' --file=$$p$$i --export-area-drawing --without-gui --export-eps=$$p$$o'], rc_entry = [ r'''\converter svg eps "%%" "" \converter svgz eps "%%" ""'''], path = ['', inkscape_path])