On 21 Mar 2014 at 10:07:21 , Vincent van Ravesteijn (v...@lyx.org) wrote: From: Benjamin Piwowarski <bpiwo...@lyx.org> Date: Fri, 14 Mar 2014 10:48:40 +0000 (+0100) Subject: Fix problem with python and change of PATH X-Git-Url: http://git.lyx.org/?p=lyx.git;a=commitdiff_plain;h=49b943e8458c6d23a7db29033e92601c7404fff5
Fix problem with python and change of PATH - waits that lyxrc has been read before finding python - when the PATH changes, resets the value --- << "\tbinary_dir " << binary_dir().absFileName() << '\n' @@ -156,6 +151,19 @@ Package::Package(string const & command_line_arg0, << "</package>\n"); } +std::string const & Package::configure_command() const +{ + if (configure_command_.empty()) { + std::string &command = const_cast<std::string&>(configure_command_); + FileName const configure_script(addName(system_support().absFileName(), "configure.py")); + command = os::python() + ' ' + + quoteName(configure_script.toFilesystemEncoding()) + + with_version_suffix() + " --binary-dir=" + + quoteName(FileName(binary_dir().absFileName()).toFilesystemEncoding()); + } + return configure_command_; +} + Either deconsitfy this function, or make configure_command_ a mutable member. In any case, do not use const_cast<>. Moreover, try not to use non-const references if not explicitly needed. Especially not if it points to a variable that is used in the same function under a different name. OK, I check the docs about development style but found no clue about what is best. I would tend to use a mutable since it is not supposed to change the overall outcome of the method. Or maybe better, this value can be recomputed each time (they are not that many calls to configure_command) -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"); + if (reset) { + command = python2("python -tt"); + } if (command.empty()) { // It was not, so check whether we can find it elsewhere in I don't know whether I completely like this. Maybe we should have Package store the value of the python interpreter, and make an explicit function: findPython to update the member. I think the overall python finding should be changed, but this was to provide a reasonable fix to the problem of the PATH changing with a relative path for python benjamin