commit 0fc6cfcdcb78e537b183767474bcdea094fd9f0d
Author: Benjamin Piwowarski <bpiwo...@lyx.org>
Date:   Fri Mar 14 11:48:40 2014 +0100

    Fix problem with python and change of PATH
    
    - waits that lyxrc has been read before finding python
    - when the PATH changes, resets the value

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index c59cb8e..666f373 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -2987,6 +2987,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
        case LyXRC::RC_PATH_PREFIX:
                if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
                        prependEnvPath("PATH", lyxrc_new.path_prefix);
+                       // Resets python path
+                       support::os::python(true);
                }
        case LyXRC::RC_PREVIEW:
        case LyXRC::RC_PREVIEW_HASHED_LABELS:
diff --git a/src/support/Package.cpp b/src/support/Package.cpp
index 61bce68..e8bef81 100644
--- a/src/support/Package.cpp
+++ b/src/support/Package.cpp
@@ -159,11 +159,6 @@ Package::Package(string const & command_line_arg0,
        explicit_user_support_dir_ = userSupportDir(default_user_support_dir,
                                     command_line_user_support_dir, 
user_support_dir_);
 
-       FileName const configure_script(addName(system_support().absFileName(), 
"configure.py"));
-       configure_command_ = os::python() + ' ' +
-                       quoteName(configure_script.toFilesystemEncoding(), 
quote_python) +
-                       with_version_suffix();
-
        LYXERR(Debug::INIT, "<package>\n"
                << "\tbinary_dir " << binary_dir().absFileName() << '\n'
                << "\tsystem_support " << system_support().absFileName() << '\n'
@@ -176,6 +171,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_;
+}
+
 
 void Package::set_temp_dir(FileName const & temp_dir) const
 {
diff --git a/src/support/Package.h b/src/support/Package.h
index 94e191c..08386b4 100644
--- a/src/support/Package.h
+++ b/src/support/Package.h
@@ -144,7 +144,7 @@ public:
         *  Caution: This is "ready-to-run", i.e. in the locale encoding, not
         *  utf8.
         */
-       std::string const & configure_command() const { return 
configure_command_; }
+       std::string const & configure_command() const;
 
 private:
        FileName binary_dir_;
diff --git a/src/support/os.cpp b/src/support/os.cpp
index aa2da7f..8f60c68 100644
--- a/src/support/os.cpp
+++ b/src/support/os.cpp
@@ -60,10 +60,13 @@ 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");
+       if (reset) {
+               command = python2("python -tt");
+       }
 
        if (command.empty()) {
                // It was not, so check whether we can find it elsewhere in
diff --git a/src/support/os.h b/src/support/os.h
index d66173b..73eb86d 100644
--- a/src/support/os.h
+++ b/src/support/os.h
@@ -59,7 +59,8 @@ shell_type shell();
 int timeout_min();
 
 /// Name of the python interpreter
-std::string const python();
+/// @param reset True if the python path should be recomputed
+std::string const python(bool reset = false);
 
 ///
 bool isFilesystemCaseSensitive();

Reply via email to