]> git.lyx.org Git - features.git/commitdiff
Revert "Fix bug #11712."
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 12 Feb 2020 15:11:01 +0000 (16:11 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 12 Feb 2020 15:11:01 +0000 (16:11 +0100)
This breaks on Linux

This reverts commit fdf81a9bab2f4f50a3eaf22cc0e09ac454f470ed.

src/support/filetools.cpp
src/support/os.cpp

index bca242d376427d2489c79a4f642ac4a965984f12..e8119959fd66314a7e6a1c842fb6a086fb161ca8 100644 (file)
@@ -635,7 +635,7 @@ string const addName(string const & path, string const & fname)
 
        if (path != "." && path != "./" && !path.empty()) {
                buf = os::internal_path(path);
-               if (!suffixIs(buf, '/'))
+               if (!suffixIs(path, '/'))
                        buf += '/';
        }
 
@@ -1039,7 +1039,7 @@ cmd_ret const runCommand(string const & cmd)
                command = rtrim(command, "2>&1");
                err2out = true;
        }
-       string const cmdarg = "/d /c \"" + command+"\"";
+       string const cmdarg = "/d /c " + command;
        string const comspec = getEnv("COMSPEC");
 
        security.nLength = sizeof(SECURITY_ATTRIBUTES);
index b1e4e09b8eb0d9c38e0b64be93bd35bb174c9ab8..10430bf5a2e756b766cf1c46e7279790f775d412 100644 (file)
@@ -48,7 +48,7 @@ int timeout_min()
 
 static string const python23_call(string const & binary, bool verbose = false)
 {
-       const string version_info = " -c \"from __future__ import print_function;import sys; print(sys.version_info[:2], end=\\\"\\\")\"";
+       const string version_info = " -c 'from __future__ import print_function;import sys; print(sys.version_info[:2], end=\"\")'";
        // Default to "python" if no binary is given.
        if (binary.empty())
                return "python -tt";
@@ -89,31 +89,49 @@ static string const find_python_binary()
        // PEP 397 -- Python launcher for Windows
        // https://www.python.org/dev/peps/pep-0397/
 
-       // Check through python launcher whether python3 is
-       // installed on computer.
-       string command = python23_call("py -3");
+       // Check whether python3 in PATH is the right one.
+       string command = python23_call("python3");
        if (!command.empty())
                return command;
 
+       // python3 does not exists, let us try to find python3.x in PATH
+       // the search is probably broader than required
+       // but we are trying hard to find a valid python binary
+       vector<string> const path = getEnvPath("PATH");
+       lyxerr << "Looking for python 3.x ...\n";
+       for (auto bin : path) {
+               QString const dir = toqstr(bin);
+               string const localdir = dir.toLocal8Bit().constData();
+               QDir qdir(dir);
+               qdir.setFilter(QDir::Files | QDir::Executable);
+               QStringList list = qdir.entryList(QStringList("python3*"));
+               for (auto bin2 : list) {
+                       string const binary = addName(localdir,
+                               bin2.toLocal8Bit().constData());
+                       command = python23_call(binary, true);
+                       if (!command.empty())
+                               return command;
+               }
+       }
+
        // python 3 was not found let us look for python 2
-       command = python23_call("py -2");
+       command = python23_call("python2");
        if (!command.empty())
                return command;
 
-       // python3 does not exists, let us try to find python3.x in PATH
+       // python2 does not exists, let us try to find python2.x in PATH
        // the search is probably broader than required
        // but we are trying hard to find a valid python binary
-       vector<string> const path = getEnvPath("PATH");
-       lyxerr << "Looking for python in PATH ...\n";
+       lyxerr << "Looking for python 2.x ...\n";
        for (auto bin : path) {
                QString const dir = toqstr(bin);
                string const localdir = dir.toLocal8Bit().constData();
                QDir qdir(dir);
                qdir.setFilter(QDir::Files | QDir::Executable);
-               QStringList list = qdir.entryList(QStringList("python*"));
+               QStringList list = qdir.entryList(QStringList("python2*"));
                for (auto bin2 : list) {
-                       string const binary = "\"" + addName(localdir,
-                               bin2.toLocal8Bit().constData()) + "\"";
+                       string const binary = addName(localdir,
+                               bin2.toLocal8Bit().constData());
                        command = python23_call(binary, true);
                        if (!command.empty())
                                return command;