On 08/09/2011 2:36 PM, Stephan Witt wrote:
Am 08.09.2011 um 14:14 schrieb Julien Rioux:

On 08/09/2011 10:12 AM, Enrico Forestieri wrote:
On Thu, Sep 08, 2011 at 01:59:23AM +0200, jri...@lyx.org wrote:
Author: jrioux
Date: Thu Sep  8 01:59:23 2011
New Revision: 39643
URL: http://www.lyx.org/trac/changeset/39643

Log:
* configure.py : Fix the detection of tex2lyx when running in-place (#6986).
Remove the hack with os.environ and instead directly search for
../src/tex2lyx/tex2lyx relative to where configure.py is found.

Modified:
    lyx-devel/trunk/lib/configure.py

Modified: lyx-devel/trunk/lib/configure.py
==============================================================================
--- lyx-devel/trunk/lib/configure.py    Thu Sep  8 01:59:14 2011        (r39642)
+++ lyx-devel/trunk/lib/configure.py    Thu Sep  8 01:59:23 2011        (r39643)
@@ -617,24 +617,21 @@

      checkLuatex()

-    ''' If we're running LyX in-place then tex2lyx will be found in
-            ../src/tex2lyx. Add this directory to the PATH temporarily and
-            search for tex2lyx.
-            Use PATH to avoid any problems with paths-with-spaces.
-    '''
-    path_orig = os.environ["PATH"]
-    os.environ["PATH"] = os.path.join('..', 'src', 'tex2lyx') + \
-        os.pathsep + path_orig
+    # Look for tex2lyx in this order (see bugs #3308 and #6986):
+    #   1)  If we're running LyX in-place then tex2lyx will be found
+    #       in ../src/tex2lyx with respect to the srcdir.
+    #   2)  If LyX was configured with a version suffix then tex2lyx
+    #       will also have this version suffix.
+    #   3)  Otherwise always use tex2lyx.
+    in_place = os.path.join('srcdir', '..', 'src', 'tex2lyx', 'tex2lyx')
+    in_place = os.path.abspath(in_place)

You should not put single quotes around srcdir.

Fixed, thanks. I tested but committed on a different machine and forgot this 
fixup.

However, this is still
going to fail as I think that nobody builds lyx directly in srcdir, i.e.,
srcdir != builddir and thus the in-place tex2lyx will not be found, still.


I do build in-place, so that makes at least one person. I think I always just 
followed what's described in README, INSTALL, and INSTALL.autoconf

The only solution I foresee is adding another option to configure.py
(--with-tex2lyx /path/to/tex2lyx) and letting lyx call it using this
option, as lyx knows whether it has been called in place and where this
place is.


Autoconf preserves the directory structure. Do scons and cmake preserve the 
directory structure? Then passing --builddir would be sufficient and might be 
more versatile in case we need to look for more stuff besides just tex2lyx.

Maybe I miss something, but Cmake doesn't preserve the directory structure on 
Mac. Here I get the binaries in the following directory tree:

$builddir/src/tex2lyx/lyx.build/Debug/tex2lyx.build/Objects-normal/i386/tex2lyx.o
....
$builddir/bin/Debug/LyX
$builddir/bin/Debug/tex2lyx
....

Stephan

Here's a patch for tex2lyx detection, out-of-source build, for autoconf and cmake. A bit complicated by the lyx and tex2lyx binaries ending up in either the same dir or a subdir, and with version suffix or not, depending on the build system.

--
Julien
Index: src/support/Package.cpp
===================================================================
--- src/support/Package.cpp	(revision 39645)
+++ src/support/Package.cpp	(working copy)
@@ -140,6 +140,8 @@
 	configure_command_ = os::python() + ' ' +
 			quoteName(configure_script.toFilesystemEncoding(), quote_python) +
 			with_version_suffix();
+	configure_command_ += " --bin-dir=" +
+			quoteName(FileName(binary_dir().absFileName()).toFilesystemEncoding(), quote_python);
 
 	LYXERR(Debug::INIT, "<package>\n"
 		<< "\tbinary_dir " << binary_dir().absFileName() << '\n'
Index: lib/configure.py
===================================================================
--- lib/configure.py	(revision 39645)
+++ lib/configure.py	(working copy)
@@ -619,14 +619,23 @@
 
     # Look for tex2lyx in this order (see bugs #3308 and #6986):
     #   1)  If we're running LyX in-place then tex2lyx will be found
-    #       in ../src/tex2lyx with respect to the srcdir.
+    #         - in the bin/tex2lyx subdir (autoconf), or
+    #         - in the bin dir, possibly with a version suffix (cmake).
     #   2)  If LyX was configured with a version suffix then tex2lyx
     #       will also have this version suffix.
     #   3)  Otherwise always use tex2lyx.
-    in_place = os.path.join(srcdir, '..', 'src', 'tex2lyx', 'tex2lyx')
-    in_place = os.path.abspath(in_place)
+    in_place1 = os.path.join(bindir, 'tex2lyx', 'tex2lyx')
+    in_place1 = os.path.abspath(in_place1)
+    tex2lyx_instances = [in_place1]
+    path = os.environ["PATH"].split(os.pathsep)
+    if bindir not in path:
+        in_place2 = os.path.join(bindir, 'tex2lyx' + version_suffix)
+        in_place2 = os.path.abspath(in_place2)
+        tex2lyx_instances.append(in_place2)
+    tex2lyx_instances.append('tex2lyx' + version_suffix)
+    tex2lyx_instances.append('tex2lyx')
 
-    path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [in_place, 'tex2lyx' + version_suffix, 'tex2lyx'],
+    path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', tex2lyx_instances,
         rc_entry = [r'''\converter latex      lyx        "%% -f $$i $$o"	""
 \converter literate   lyx        "%% -n -f $$i $$o"	""'''], not_found = 'tex2lyx')
     if path == '':
@@ -1313,6 +1322,7 @@
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
+    bindir = ''
     ## Parse the command line
     for op in sys.argv[1:]:   # default shell/for list is $*, the options
         if op in [ '-help', '--help', '-h' ]:
@@ -1330,6 +1340,8 @@
             lyx_keep_temps = True
         elif op[0:22] == '--with-version-suffix=':  # never mind if op is not long enough
             version_suffix = op[22:]
+        elif op[0:10] == '--bin-dir=':
+            bindir = op[10:]
         else:
             print "Unknown option", op
             sys.exit(1)
@@ -1338,6 +1350,8 @@
     srcdir = os.path.dirname(sys.argv[0])
     if srcdir == '':
         srcdir = '.'
+    if bindir == '':
+        bindir = os.path.join(srcdir, '..', 'src')
     if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ):
         logger.error("configure: error: cannot find chkconfig.ltx script")
         sys.exit(1)

Reply via email to