About text: Add Python version

#10224 About text: Add Python version
This commit is contained in:
Magne Sjaastad 2023-06-02 14:04:23 +02:00 committed by GitHub
parent ca4d05dec9
commit 709457f7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View File

@ -32,3 +32,5 @@
#define RESINSIGHT_PATCH_VERSION "@RESINSIGHT_PATCH_VERSION@"
#define RESINSIGHT_OCTAVE_VERSION "@OCTAVE_VERSION_STRING@"
#define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@"

View File

@ -55,6 +55,12 @@ if(Qt5Core_FOUND)
endif(Qt5Charts_FOUND)
endif(Qt5Core_FOUND)
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
set(Python3_EXECUTABLE ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
find_package(Python3)
message(STATUS "Using Python Version: ${Python3_VERSION}")
endif()
# NB: The generated file is written to Cmake binary folder to avoid source tree
# pollution This folder is added to include_directories
configure_file(

View File

@ -23,6 +23,7 @@
#include "RiaApplication.h"
#include "RiaBaseDefs.h"
#include "RiaNetworkTools.h"
#include "RiaPreferences.h"
#include "RiaVersionInfo.h"
#include "RiuMainWindow.h"
@ -155,6 +156,19 @@ void RicHelpAboutFeature::onActionTriggered( bool isChecked )
dlg.addVersionEntry( " ", QString( " " ) + vendor + " : " + render );
}
QString compiledUsingPythonVersion = RESINSIGHT_PYTHON_VERSION;
if ( !compiledUsingPythonVersion.isEmpty() )
{
auto pythonRuntimePath = RiaPreferences::current()->pythonExecutable();
auto pythonRuntimeVersion = RicHelpAboutFeature::getPythonVersion( pythonRuntimePath );
dlg.addVersionEntry( " ", "" );
dlg.addVersionEntry( " ", "Python" );
dlg.addVersionEntry( " ", QString( " Compiled with: Python " ) + compiledUsingPythonVersion );
dlg.addVersionEntry( " ", QString( " Runtime binary: " ) + pythonRuntimePath );
dlg.addVersionEntry( " ", QString( " Runtime version: " ) + pythonRuntimeVersion );
}
dlg.create();
dlg.resize( 300, 200 );
@ -170,6 +184,27 @@ void RicHelpAboutFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setIcon( QIcon( ":/HelpCircle.svg" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicHelpAboutFeature::getPythonVersion( const QString& pathToPythonExecutable )
{
QStringList arguments;
arguments << "--version";
QProcess process;
process.setProgram( pathToPythonExecutable );
process.setArguments( arguments );
process.start();
process.waitForFinished();
QByteArray output = process.readAllStandardOutput();
QString versionString = QString( output ).trimmed();
return versionString;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,8 @@ class RicHelpAboutFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static QString getPythonVersion( const QString& pathToPythonExecutable );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;