From 721baac3fa8205646d84682987457313a3b05edd Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Fri, 17 Aug 2018 14:25:18 -0400 Subject: [PATCH 1/2] ENH: set sys.executable in python to 'PythonSlicer' Allows sys.executable to be used to find a functioning interpreter. --- Base/QTCore/qSlicerCoreApplication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Base/QTCore/qSlicerCoreApplication.cxx b/Base/QTCore/qSlicerCoreApplication.cxx index 00c6a4bdf..d1b6baedc 100644 --- a/Base/QTCore/qSlicerCoreApplication.cxx +++ b/Base/QTCore/qSlicerCoreApplication.cxx @@ -902,7 +902,7 @@ void qSlicerCoreApplication::handleCommandLineArguments() // Set 'sys.executable' so that Slicer can be used as a "regular" python interpreter this->corePythonManager()->executeString( - QString("import sys; sys.executable = '%1'; del sys").arg(this->applicationFilePath())); + QString("import sys; sys.executable = '%1'; del sys").arg(QStandardPaths::findExecutable("PythonSlicer"))); // Clean memory for(int i = 0; i < pythonArgc; ++i){ delete[] pythonArgv[i];} -- GitLab From eefb467dc38b44b6dcc8a4e3f48a3e8a99864b63 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Fri, 17 Aug 2018 21:51:08 -0400 Subject: [PATCH 2/2] ENH: use distutils.spawn.find_executable sys.executable on qt4 Instead of QStandardPaths --- Base/QTCore/qSlicerCoreApplication.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Base/QTCore/qSlicerCoreApplication.cxx b/Base/QTCore/qSlicerCoreApplication.cxx index d1b6baedc..e7ac24975 100644 --- a/Base/QTCore/qSlicerCoreApplication.cxx +++ b/Base/QTCore/qSlicerCoreApplication.cxx @@ -902,7 +902,12 @@ void qSlicerCoreApplication::handleCommandLineArguments() // Set 'sys.executable' so that Slicer can be used as a "regular" python interpreter this->corePythonManager()->executeString( - QString("import sys; sys.executable = '%1'; del sys").arg(QStandardPaths::findExecutable("PythonSlicer"))); + #if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0)) + QString("import sys; sys.executable = '%1'; del sys").arg(QStandardPaths::findExecutable("PythonSlicer")) + #else + QString("import sys, distutils.spawn; sys.executable = distutils.spawn.find_executable('PythonSlicer'); del sys, distutils") + #endif + ); // Clean memory for(int i = 0; i < pythonArgc; ++i){ delete[] pythonArgv[i];} -- GitLab