On Sun, 2022-07-31 at 11:16 +0200, Pavel Sanda wrote:
> Sure, whatever you need :)
> The patch is in.
> 
> Pavel

First attempt. :-)

The code is straightforward, on my system it works in both python2 and
python3. FWIW the only difference is:

--- configure2.log      2022-07-31 11:32:45.733253492 +0100
+++ configure.log       2022-07-31 11:33:20.607195627 +0100
@@ -1,4 +1,4 @@
-INFO: +Running LyX configure with Python 2.7.18
+INFO: +Running LyX configure with Python 3.10.5
 INFO: checking for a Latex2e program...
 DEBUG: (latex $$i,latex2e $$i)
 INFO: +checking for "latex"...  yes

And of course that is the expected.

FWIW the code should work on any system/OS... famous last words, I
know. :-D

Please test it.
-- 
José Abílio
diff --git a/lib/configure.py b/lib/configure.py
index ab205dd7b4..baf82929cb 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1174,8 +1174,18 @@ def checkConverterEntries():
     checkProg('an EPS -> PDF converter', ['epstopdf'],
         rc_entry = [ r'\converter eps        pdf6       "epstopdf --outfile=$$o $$i"	""'])
     #
-    checkProg('an EPS -> PNG converter', ['magick $$i[0] $$o', 'convert $$i[0] $$o'],
-        rc_entry = [ r'\converter eps        png        "%%"	""'])
+    # Due to more restrictive policies, it is possible that (image)magick
+    # does not allow conversions from eps to png.
+    # So before setting the converter test it it on a mock file
+    _, cmd = checkProg('an EPS -> PNG converter', ['magick', 'convert'])
+    if cmd:
+        writeToFile('mock.eps', r'%!PS')
+        if subprocess.check_call([cmd, "mock.eps", "mock.png"]) == 0:
+            rc_entry = r'\converter eps        png        "%s $$i[0] $$o"	""'
+            addToRC(rc_entry % cmd)
+            removeFiles(['mock.eps', 'mock.png'])
+        else:
+            removeFiles(['mock.eps'])
     #
     # no agr -> pdf6 converter, since the pdf library used by gracebat is not
     # free software and therefore not compiled in in many installations.
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to