Op 2-8-2013 13:03, Stephan Witt schreef:
Am 02.08.2013 um 12:47 schrieb Vincent van Ravesteijn <v...@lyx.org>:
On Fri, Aug 2, 2013 at 12:22 PM, Stephan Witt <st.w...@gmx.net> wrote:
Am 02.08.2013 um 12:13 schrieb Vincent van Ravesteijn <v...@lyx.org>:
On Fri, Aug 2, 2013 at 12:00 PM, Stephan Witt <st.w...@gmx.net> wrote:
With your patch we look for the 'tex2lyx' binary in the directory
<lyx_binary_dir>/tex2lyx. My latest change made it possible to also look in
<lyx_binary_dir>.
Because of the variable naming I didn't got it.
This was needed for CMake builds and is no longer possible now.
Ok, so this updated patch is correct then?
Stephan
No, because checkProg writes an entry with addToRC and it omits the path itself (as it
probably assumes that it is in the "PATH" environment variable). So, our
customly supplied path is lost.
So, then our customly supplied path has to be added to PATH by LyX too
I'd rather do something like the following:
{{{
env_path = os.environ["PATH"]
....
for ac_dir in path + env_path:
...
if ac_dir in path:
addToRC(rc_entry[0].replace('%%', os.path.join(path, ac_prog))
else
addToRC(rc_entry[0].replace('%%', ac_prog)
...
}}}
This alters the behaviour of this function, but I don't seem to be able to find
a case where we actually use this path variable, so it might be safe to do
this. If you do so, please check whether it was actually used or not.
Vincent
I've tried this already. It ends up with illegal(?) converter lines:
\converter latex lyx "/tmp/lyx-build/LyX 2.1.0dev.build/src/tex2lyx/tex2lyx -f $$i
$$o" ""
\converter literate lyx "/tmp/lyx-build/LyX 2.1.0dev.build/src/tex2lyx/tex2lyx -n -m
noweb -f $$i $$o" ""
How should the space in the path name be escaped?
I think the only safe solution is to add lyx_binary_dir and
lyx_binary_dir+"/tex2lyx" to PATH.
Stephan
So, what do you think of the attached patch ?
Vincent
commit 7bf4a4fd1ca15c839d589fee481fe623402c94da
Author: Vincent van Ravesteijn <v...@lyx.org>
Date: Fri Aug 2 22:36:22 2013 +0200
configure: Fix tex2lyx converter entries with spaces
When searching for programs, a search path can be supplied to checkProg and
checkAlternative. If a program is found, the search path must be added to the
rc entry. Besides this, if the path has spaces, the command needs to be quoted
as well.
diff --git a/lib/configure.py b/lib/configure.py
index c7f7ce2..fb3c105 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -193,11 +193,11 @@ def checkProg(description, progs, rc_entry = [], path =
[], not_found = ''):
if ac_word.endswith('.pl') and perl == '':
continue
msg = '+checking for "' + ac_word + '"... '
- path = os.environ["PATH"].split(os.pathsep) + path
+ env_path = os.environ["PATH"].split(os.pathsep)
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
- for ac_dir in path:
+ for ac_dir in path + env_path:
if hasattr(os, "access") and not os.access(ac_dir, os.F_OK):
continue
for ext in extlist:
@@ -210,6 +210,13 @@ def checkProg(description, progs, rc_entry = [], path =
[], not_found = ''):
ac_prog = ac_prog.replace(ac_word, r'%s -jar \"%s\"' %
(java, os.path.join(ac_dir, ac_word)))
elif ac_word.endswith('.pl'):
ac_prog = ac_prog.replace(ac_word, r'%s -w \"%s\"' %
(perl, os.path.join(ac_dir, ac_word)))
+ else:
+ if ac_dir in path:
+ command = os.path.join(ac_dir, ac_word)
+ if command.find(' ') != -1:
+ command = "\\\"" + command + "\\\""
+ ac_prog = ac_prog.replace(ac_word, command)
+
# write rc entries for this command
if len(rc_entry) == 1:
addToRC(rc_entry[0].replace('%%', ac_prog))
@@ -248,12 +255,12 @@ def checkProgAlternatives(description, progs, rc_entry =
[], alt_rc_entry = [],
if ac_word.endswith('.pl') and perl == '':
continue
msg = '+checking for "' + ac_word + '"... '
- path = os.environ["PATH"].split(os.pathsep) + path
+ env_path = os.environ["PATH"].split(os.pathsep)
extlist = ['']
if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
found_alt = False
- for ac_dir in path:
+ for ac_dir in path + env_path:
if hasattr(os, "access") and not os.access(ac_dir, os.F_OK):
continue
for ext in extlist:
@@ -268,6 +275,12 @@ def checkProgAlternatives(description, progs, rc_entry =
[], alt_rc_entry = [],
ac_prog = ac_prog.replace(ac_word, r'%s -jar \"%s\"' %
(java, os.path.join(ac_dir, ac_word)))
elif ac_word.endswith('.pl'):
ac_prog = ac_prog.replace(ac_word, r'%s -w \"%s\"' %
(perl, os.path.join(ac_dir, ac_word)))
+ else:
+ if ac_dir in path:
+ command = os.path.join(ac_dir, ac_word)
+ if command.find(' ') != -1:
+ command = "\\\"" + command + "\\\""
+ ac_prog = ac_prog.replace(ac_word, command)
# write rc entries for this command
if found_prime == False:
if len(rc_entry) == 1:
@@ -657,13 +670,11 @@ def checkConverterEntries():
# 3) If LyX was configured with a version suffix then tex2lyx
# will also have this version suffix.
# 4) Otherwise always use tex2lyx.
- in_binary_subdir = os.path.join(lyx_binary_dir, 'tex2lyx', 'tex2lyx')
- in_binary_subdir = os.path.abspath(in_binary_subdir)
-
- in_binary_dir = os.path.join(lyx_binary_dir, 'tex2lyx')
- in_binary_dir = os.path.abspath(in_binary_dir)
+ in_binary_subdir = os.path.join(lyx_binary_dir, 'tex2lyx')
+ in_binary_dir = os.path.abspath(lyx_binary_dir)
- path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [in_binary_subdir,
in_binary_subdir + version_suffix, in_binary_dir, in_binary_dir +
version_suffix, 'tex2lyx' + version_suffix, 'tex2lyx'],
+ path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', ['tex2lyx' +
version_suffix, 'tex2lyx'],
+ path = [in_binary_subdir, in_binary_dir],
rc_entry = [r'''\converter latex lyx "%% -f $$i $$o"
""
\converter literate lyx "%% -n -m noweb -f $$i $$o" ""'''],
not_found = 'tex2lyx')
if path == '':