[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-cvs
Subject:    [LyX/master] add inkscape wrapper script for Mac OS
From:       Stephan Witt <switt () lyx ! org>
Date:       2017-09-24 9:55:38
Message-ID: 20170924095538.D89AD2801F6 () lyx ! lyx ! org
[Download RAW message or body]

commit 350ef993e59b3ede7dd621a81f096ea78296c5c8
Author: Stephan Witt <switt@lyx.org>
Date:   Sun Sep 24 11:54:55 2017 +0200

    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(-)

diff --git a/development/MacOSX/Makefile.am b/development/MacOSX/Makefile.am
index b9cdfa6..9ca0c22 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 0000000..bc34e86
--- /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 a674032..e9b7890 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])


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic