]> git.lyx.org Git - lyx.git/commitdiff
#12523 check for existence of usable Python interpreter
authorStephan Witt <switt@lyx.org>
Thu, 5 Jan 2023 23:32:09 +0000 (00:32 +0100)
committerStephan Witt <switt@lyx.org>
Thu, 5 Jan 2023 23:32:09 +0000 (00:32 +0100)
- present appropriate alert message in case of missing Python
- add the option to quit LyX immediately
- recheck for Python interpreter on reconfigure if it was missing

src/LyX.cpp
src/support/Package.cpp
src/support/os.cpp
src/support/os.h

index fc2f87110176850254fcc9e6791e051d39821cfd..2a7cba35abbc048d3e9628c861767da016ee6c6d 100644 (file)
@@ -581,10 +581,11 @@ void LyX::execCommands()
 {
        // The advantage of doing this here is that the event loop
        // is already started. So any need for interaction will be
-       // aknowledged.
+       // acknowledged.
 
        // if reconfiguration is needed.
-       if (LayoutFileList::get().empty()) {
+       const bool noLayouts = LayoutFileList::get().empty();
+       if (noLayouts && os::hasPython()) {
                switch (Alert::prompt(
                        _("No textclass is found"),
                        _("LyX will only have minimal functionality because no textclasses "
@@ -593,7 +594,8 @@ void LyX::execCommands()
                        0, 2,
                        _("&Reconfigure"),
                        _("&Without LaTeX"),
-                       _("&Continue")))
+                       _("&Continue"),
+                       _("&Exit LyX")))
                {
                case 0:
                        // regular reconfigure
@@ -604,6 +606,24 @@ void LyX::execCommands()
                        lyx::dispatch(FuncRequest(LFUN_RECONFIGURE,
                                " --without-latex-config"));
                        break;
+               case 3:
+                       lyx::dispatch(FuncRequest(LFUN_LYX_QUIT, ""));
+                       return;
+               default:
+                       break;
+               }
+       } else if (noLayouts) {
+               switch (Alert::prompt(
+                       _("No python is found"),
+                       _("LyX will only have minimal functionality because no python interpreter "
+                               "has been found. Consider download and install of an python interpreter."),
+                       0, 1,
+                       _("&Continue"),
+                       _("&Exit LyX")))
+               {
+               case 1:
+                       lyx::dispatch(FuncRequest(LFUN_LYX_QUIT, ""));
+                       return;
                default:
                        break;
                }
index 400bf15707c98ead5eaa9cb5377e9a869ed9f1ea..ffc1395efb5ac33f243c1fd126da691918605097 100644 (file)
@@ -159,9 +159,9 @@ Package::Package(string const & command_line_arg0,
 
 int Package::reconfigureUserLyXDir(string const & option) const
 {
-       if (configure_command_.empty()) {
+       if (configure_command_.empty() || !os::hasPython()) {
                FileName const configure_script(addName(system_support().absFileName(), "configure.py"));
-               configure_command_ = os::python() + ' ' +
+               configure_command_ = os::python(true) + ' ' +
                        quoteName(configure_script.toFilesystemEncoding()) +
                        with_version_suffix() + " --binary-dir=" +
                        quoteName(FileName(binary_dir().absFileName()).toFilesystemEncoding());
index cafe4b1cb9dd6851db3ceda686de5d871919ebef..abb9ec6d672d32eae81f477914f6104723021743 100644 (file)
@@ -191,6 +191,12 @@ string const python(bool reset)
        return command;
 }
 
+
+bool hasPython()
+{
+       return !(python23_call(python()).empty());
+}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
index d89af7dca46a98c6489d9231f9974ad038f90fff..a96791dff43ee7a63e785f3374e6a031749f05e4 100644 (file)
@@ -62,6 +62,9 @@ int timeout_ms();
 /// @param reset True if the python path should be recomputed
 std::string const python(bool reset = false);
 
+/// Check for availbility of the python interpreter
+bool hasPython();
+
 ///
 bool isFilesystemCaseSensitive();