X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fos.cpp;h=ec84ed1394e6ae6ba48b9038af3093c42033605d;hb=3561caa3a171a5984ee7a10b7ea82f7f4b7226e8;hp=aa2da7f1746be1bda515b2cb7cb59e6d4ebc3c8a;hpb=56cbb9eb1174838fd8ede97793d6f63870f800d5;p=lyx.git diff --git a/src/support/os.cpp b/src/support/os.cpp index aa2da7f174..ec84ed1394 100644 --- a/src/support/os.cpp +++ b/src/support/os.cpp @@ -30,7 +30,7 @@ // e.g., the author hash is always 32-bit. template struct static_assert_helper; template <> struct static_assert_helper {}; -enum { +enum { dummy = sizeof(static_assert_helper) }; @@ -38,14 +38,16 @@ namespace lyx { namespace support { namespace os { -static string const python2(string const & binary, bool verbose = false) +static string const python23(string const & binary, bool verbose = false) { if (verbose) lyxerr << "Examining " << binary << "\n"; - // Check whether this is a python 2 binary. + // Check whether this is a python 2 or 3 binary. cmd_ret const out = runCommand(binary + " -V 2>&1"); - if (out.first < 0 || !prefixIs(out.second, "Python 2")) + if (out.first < 0 || + (!prefixIs(out.second, "Python 2") && + !prefixIs(out.second, "Python 3"))) return string(); if (verbose) @@ -60,10 +62,14 @@ int timeout_min() } -string const python() +string const python(bool reset) { // Check whether the first python in PATH is the right one. - static string command = python2("python -tt"); + static string command = python23("python -tt"); + // FIXME THREAD + if (reset) { + command = python23("python -tt"); + } if (command.empty()) { // It was not, so check whether we can find it elsewhere in @@ -71,7 +77,7 @@ string const python() vector const path = getEnvPath("PATH"); vector::const_iterator it = path.begin(); vector::const_iterator const end = path.end(); - lyxerr << "Looking for python v2.x ...\n"; + lyxerr << "Looking for python v2.x or 3.x ...\n"; for (; it != end; ++it) { QString const dir = toqstr(*it); string const localdir = dir.toLocal8Bit().constData(); @@ -81,13 +87,13 @@ string const python() for (int i = 0; i < list.size() && command.empty(); ++i) { string const binary = addName(localdir, list.at(i).toLocal8Bit().constData()); - command = python2(binary, true); + command = python23(binary, true); } } // Default to "python" if no usable binary was found. if (command.empty()) { - lyxerr << "Warning: No python v2.x binary found.\n"; + lyxerr << "Warning: No python v2.x or 3.x binary found.\n"; command = "python"; } @@ -98,6 +104,6 @@ string const python() return command; } -} -} -} +} // namespace os +} // namespace support +} // namespace lyx