]> git.lyx.org Git - features.git/commitdiff
add inkscape wrapper script for Mac OS
authorStephan Witt <switt@lyx.org>
Sun, 24 Sep 2017 09:54:55 +0000 (11:54 +0200)
committerStephan Witt <switt@lyx.org>
Sun, 24 Sep 2017 09:55:20 +0000 (11:55 +0200)
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
development/MacOSX/inkscape [new file with mode: 0755]
lib/configure.py

index b9cdfa65752701da81629cce41ce3817693b5e1c..9ca0c22a5f12b84fa655a9311418127f6d638acb 100644 (file)
@@ -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 (executable)
index 0000000..bc34e86
--- /dev/null
@@ -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
index a6740327ca4384bcf3c05f0143ffbf8ae676bf78..e9b789085e76caa5372eb06a8efba6001266ea98 100644 (file)
@@ -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 %% $$$$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 %% $$$$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])