aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index 43d23a256bc..97d118f1229 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -3,6 +3,9 @@
#include "pythonutils.h"
+#include "pythonbuildconfiguration.h"
+#include "pythonconstants.h"
+#include "pythonkitaspect.h"
#include "pythonproject.h"
#include "pythonsettings.h"
#include "pythontr.h"
@@ -38,14 +41,12 @@ FilePath detectPython(const FilePath &documentPath)
FilePaths dirs = Environment::systemEnvironment().path();
- if (project) {
- if (auto target = project->activeTarget()) {
- if (auto runConfig = target->activeRunConfiguration()) {
- if (auto interpreter = runConfig->aspect<InterpreterAspect>())
- return interpreter->currentInterpreter().command;
- if (auto environmentAspect = runConfig->aspect<EnvironmentAspect>())
- dirs = environmentAspect->environment().path();
- }
+ if (project && project->mimeType() == Constants::C_PY_PROJECT_MIME_TYPE) {
+ if (const Target *target = project->activeTarget()) {
+ if (auto bc = qobject_cast<PythonBuildConfiguration *>(target->activeBuildConfiguration()))
+ return bc->python();
+ if (const std::optional<Interpreter> python = PythonKitAspect::python(target->kit()))
+ return python->command;
}
}
@@ -186,4 +187,9 @@ void createVenv(const Utils::FilePath &python,
process->start();
}
+bool isVenvPython(const Utils::FilePath &python)
+{
+ return python.parentDir().parentDir().contains("pyvenv.cfg");
+}
+
} // Python::Internal