On Wed, Jul 12, 2017 at 11:46:31AM +0200, Kornel Benko wrote:
> 
> I implemented it now in cmake build. At first, everything seemed to work.
> Reconfiguring lyx...
> Load examples/chessgame.lyx
>       --> The selected document class Chess requires external files ...
> Pdf creation is OK though.
> So the "configure.py" apparently does not honour the lyxrc.dist entry
> '\texinputs_prefix ".:/usr/local/share/lyx2.3/tex"'
> but compilation in lyx does (as can be seen in
> Tools->Preferences...->Paths->TEXINPUTS prefix:)
> 
> In fact, the entries in clsFiles.lst are missing now.

This is because TeXFiles.py is called without setting TEXINPUTS.
Moreover, there is also the issue that MikTeX's kpsewhich completely
ignores TEXINPUTS. However, the attached patch works for me on any
platform I have access to and with any TeX engine.

-- 
Enrico
diff --git a/lib/scripts/TeXFiles.py b/lib/scripts/TeXFiles.py
index aac29bc9d0..ab1659f3b0 100755
--- a/lib/scripts/TeXFiles.py
+++ b/lib/scripts/TeXFiles.py
@@ -77,11 +77,24 @@ else:
 # Cygwin, where we could have either teTeX (using `:') or MikTeX (using `;').
 # Create a variable that holds the right character to be used by the scripts.
 path_sep = os.pathsep
+texinputs_sep = path_sep
 if sys.platform == 'cygwin':
     if ';' in cmdOutput('kpsewhich --show-path=.tex'):
         path_sep = ';'
-    else:
-        path_sep = ':'
+    if "TEXINPUTS" in os.environ and ';' in os.environ["TEXINPUTS"]:
+        texinputs_sep = ';'
+
+# Account for absolute paths in TEXINPUTS
+texinputs_dirs = list()
+if "TEXINPUTS" in os.environ:
+    texinputs_alldirs = os.environ["TEXINPUTS"].split(texinputs_sep)
+    for dir in texinputs_alldirs:
+        if dir != "":
+            texdir = dir
+            if sys.platform == 'cygwin' and texinputs_sep == ';':
+                texdir = cmdOutput('cygpath "%s"' % dir).strip()
+            if os.path.isabs(texdir):
+                texinputs_dirs.append(texdir)
 
 # process each file type
 for type in types:
@@ -89,21 +102,27 @@ for type in types:
     if type == 'cls':
         outfile = cls_stylefile
         kpsetype = '.tex'
+        extra_dirs = texinputs_dirs
     elif type == 'sty':
         outfile = sty_stylefile
         kpsetype = '.tex'
+        extra_dirs = texinputs_dirs
     elif type == 'bst':
         outfile = bst_stylefile
         kpsetype = '.bst'
+        extra_dirs = list()
     elif type == 'bib':
         outfile = bib_files
         kpsetype = '.bib'
+        extra_dirs = list()
     elif type == 'bbx':
         outfile = bbx_files
         kpsetype = '.tex'
+        extra_dirs = list()
     elif type == 'cbx':
         outfile = cbx_files
         kpsetype = '.tex'
+        extra_dirs = list()
 
     dirs = cmdOutput('kpsewhich --show-path=' + kpsetype).replace('!!', 
'').strip()
     # remove excessive //
@@ -111,7 +130,7 @@ for type in types:
     
     file_ext = '.' + type
     out = open(outfile, 'w')
-    for dir in dirs.split(path_sep):
+    for dir in dirs.split(path_sep) + extra_dirs:
         # for each valid directory
         if not os.path.isdir(dir):
             continue
diff --git a/src/frontends/qt4/qt_helpers.cpp b/src/frontends/qt4/qt_helpers.cpp
index 3d3e36819f..6580ad2394 100644
--- a/src/frontends/qt4/qt_helpers.cpp
+++ b/src/frontends/qt4/qt_helpers.cpp
@@ -298,7 +298,9 @@ void rescanTexStyles(string const & arg)
        string const command = os::python() + ' ' +
            quoteName(prog.toFilesystemEncoding()) + ' ' +
            arg;
-       int const status = one.startscript(Systemcall::Wait, command);
+       // Force using TEXINPUTS with "." unchanged.
+       string const curdir = ".";
+       int const status = one.startscript(Systemcall::Wait, command, curdir);
        if (status == 0)
                return;
        // FIXME UNICODE
diff --git a/src/support/Package.cpp b/src/support/Package.cpp
index 75d6e1a2f8..1f7ee674b7 100644
--- a/src/support/Package.cpp
+++ b/src/support/Package.cpp
@@ -169,7 +169,10 @@ int Package::reconfigureUserLyXDir(string const & option) 
const
        lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
        PathChanger p(user_support());
        Systemcall one;
-       int const ret = one.startscript(Systemcall::Wait, configure_command_ + 
option);
+       // Force using TEXINPUTS with "." unchanged.
+       string const curdir = ".";
+       int const ret = one.startscript(Systemcall::Wait,
+                                       configure_command_ + option, curdir);
        lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
        return ret;
 }

Reply via email to