commit b2a026fbf76e82f50adf8c921a36e40ba38b5413 Author: Stephan Witt <sw...@lyx.org> Date: Wed Jun 14 12:00:41 2023 +0200
#12523 check for existence of usable Python interpreter Backport of change bbc2270 - 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 | 26 +++++++++++++++++++++++--- src/support/Package.cpp | 4 ++-- src/support/os.cpp | 6 ++++++ src/support/os.h | 3 +++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/LyX.cpp b/src/LyX.cpp index 4e97f7a..6888388 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -585,10 +585,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 " @@ -597,7 +598,8 @@ void LyX::execCommands() 0, 2, _("&Reconfigure"), _("&Without LaTeX"), - _("&Continue"))) + _("&Continue"), + _("&Exit LyX"))) { case 0: // regular reconfigure @@ -608,6 +610,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; } diff --git a/src/support/Package.cpp b/src/support/Package.cpp index 8b6fa0b..df8e57e 100644 --- a/src/support/Package.cpp +++ b/src/support/Package.cpp @@ -158,9 +158,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()); diff --git a/src/support/os.cpp b/src/support/os.cpp index ec84ed1..6c9a4a9 100644 --- a/src/support/os.cpp +++ b/src/support/os.cpp @@ -104,6 +104,12 @@ string const python(bool reset) return command; } + +bool hasPython() +{ + return !(python23(python()).empty()); +} + } // namespace os } // namespace support } // namespace lyx diff --git a/src/support/os.h b/src/support/os.h index 9b38e4e..0492bb3 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -62,6 +62,9 @@ int timeout_min(); /// @param reset True if the python path should be recomputed std::string const python(bool reset = false); +/// Check for availability of the python interpreter +bool hasPython(); + /// bool isFilesystemCaseSensitive(); -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs