From f012f1b245939f5437ae7dd3cc0b14bc005f56ee Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 18 Oct 2022 10:30:06 +0200 Subject: [PATCH] Python: try to find interpreter on device for run configuration If the default interpreter is not on the run device of the kit try to find any interpreter on that device and use it as the default interpreter for this run configuration. Change-Id: I52985281f0f1d2ac88759169400d64121299f95d Reviewed-by: Christian Stenger --- src/plugins/python/pythonrunconfiguration.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 7a370f7517e..9012556c81e 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -130,13 +132,23 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id) connect(PythonSettings::instance(), &PythonSettings::interpretersChanged, interpreterAspect, &InterpreterAspect::updateInterpreters); - QList interpreters = PythonSettings::detectPythonVenvs( + const QList interpreters = PythonSettings::detectPythonVenvs( project()->projectDirectory()); interpreterAspect->updateInterpreters(PythonSettings::interpreters()); Interpreter defaultInterpreter = interpreters.isEmpty() ? PythonSettings::defaultInterpreter() : interpreters.first(); if (!defaultInterpreter.command.isExecutableFile()) defaultInterpreter = PythonSettings::interpreters().value(0); + if (defaultInterpreter.command.isExecutableFile()) { + const IDeviceConstPtr device = DeviceKitAspect::device(target->kit()); + if (device && !device->handlesFile(defaultInterpreter.command)) { + defaultInterpreter = Utils::findOr(PythonSettings::interpreters(), + defaultInterpreter, + [device](const Interpreter &interpreter) { + return device->handlesFile(interpreter.command); + }); + } + } interpreterAspect->setDefaultInterpreter(defaultInterpreter); auto bufferedAspect = addAspect();