forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/localenvironmentaspect.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
@@ -130,13 +132,23 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id)
|
||||
connect(PythonSettings::instance(), &PythonSettings::interpretersChanged,
|
||||
interpreterAspect, &InterpreterAspect::updateInterpreters);
|
||||
|
||||
QList<Interpreter> interpreters = PythonSettings::detectPythonVenvs(
|
||||
const QList<Interpreter> 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<BoolAspect>();
|
||||
|
Reference in New Issue
Block a user