On Wed, 2023-01-18 at 11:13 -0500, Scott Kostyshak wrote:
> On Wed, Jan 18, 2023 at 08:45:22AM +0000, José Matos wrote:
> 
> > Python detected: python3 -tt
> > 
> > Thinking aloud... here we could also output the Python version, for
> > consistency sake...
> 
> +1
> 
> Scott

What about this change? With the attached patch I get:

Version 2.4.0~RC1.devel
(not released yet)

Built from git commit hash 0c6101b0
Qt Version (run-time): 5.15.10 on platform wayland
Qt Version (compile-time): 5.15.10
OS Version (run-time): Fedora Linux 39 (KDE Plasma Prerelease)
Python detected: 3.12.0rc1 (/usr/bin/python3)


We have several recent threads, for example on Mac systems, where this
output is useful without the need to go to a terminal.
IMHO it is also more relevant than what we get now.


As a bonus if no python is detected then the output is:

Python detected: None

None is not supposed to be translated, it is (Monty) Python's humour.
:-D

-- 
José Abílio
diff --git a/src/frontends/qt/GuiAbout.cpp b/src/frontends/qt/GuiAbout.cpp
index 325801c521..0a585f0eac 100644
--- a/src/frontends/qt/GuiAbout.cpp
+++ b/src/frontends/qt/GuiAbout.cpp
@@ -222,7 +222,7 @@ static QString buildinfo()
 		    << endl;
 #endif
 
-	out << lyx_version_info 
+	out << lyx_version_info
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
 	    << Qt::endl;
 #else
@@ -297,7 +297,7 @@ static QString version(bool const plain = false)
 	else
 		out << "</p><p>";
 #endif
-	out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python())));
+	out << toqstr(bformat(_("Python detected: %1$s"), from_utf8(os::python_info())));
 	if (!plain)
 		out << toqstr("</p></body></html>");
 	return res;
diff --git a/src/support/os.cpp b/src/support/os.cpp
index abb9ec6d67..27427cd8ea 100644
--- a/src/support/os.cpp
+++ b/src/support/os.cpp
@@ -58,7 +58,7 @@ int timeout_ms()
 
 static string const python23_call(string const & binary, bool verbose = false)
 {
-	const string version_info = " -c \"from __future__ import print_function;import sys; print(sys.version_info[:2], end=\\\"\\\")\"";
+	const string version_info = " -c \"from __future__ import print_function; import sys; print(sys.version_info[:2], end='')\"";
 	// Default to "python" if no binary is given.
 	if (binary.empty())
 		return "python -tt";
@@ -142,7 +142,7 @@ static string const find_python_binary()
 		return command;
 
 #ifdef _WIN32
-	// python launcher is not installed, let cmd auto check 
+	// python launcher is not installed, let cmd auto check
 	// PATH for a python.exe
 	command = python23_call("python");
 	if (!command.empty())
@@ -197,6 +197,14 @@ bool hasPython()
 	return !(python23_call(python()).empty());
 }
 
+string const python_info()
+{
+	const string info_version = " -c \"from __future__ import print_function; import sys; print('{} ({})'.format(sys.version.split()[0],sys.executable), end='')\"";
+	if (!hasPython())
+		return("None");
+	return (runCommand(python() + info_version).result);
+}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
diff --git a/src/support/os.h b/src/support/os.h
index 7e6bdbde95..35154a8c34 100644
--- a/src/support/os.h
+++ b/src/support/os.h
@@ -65,6 +65,9 @@ std::string const python(bool reset = false);
 /// Check for availability of the python interpreter
 bool hasPython();
 
+/// Return information about the ython interper
+std::string const python_info();
+
 ///
 bool isFilesystemCaseSensitive();
 
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to