forked from qt-creator/qt-creator
Python: detect virtual environments for documents and projects
After opening a document or project the directory hierarchy is looked up for a Scripts/(activate && python.exe) on windows or bin/(activate && python) on unix. This is the usual structure of python virtual environments. If such a folder is found add the python from that folder to the list of configured interpreters in the settings, set it as the current interpreter for the project and try to open the corresponding language server. Change-Id: I038c309ea2988f9370194330d250d1515beac0a0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -260,8 +260,10 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
|
||||
connect(PythonSettings::instance(), &PythonSettings::interpretersChanged,
|
||||
interpreterAspect, &InterpreterAspect::updateInterpreters);
|
||||
|
||||
interpreterAspect->updateInterpreters(PythonSettings::interpreters());
|
||||
interpreterAspect->setDefaultInterpreter(PythonSettings::defaultInterpreter());
|
||||
QList<Interpreter> interpreters = PythonSettings::detectPythonVenvs(project()->projectDirectory());
|
||||
aspect<InterpreterAspect>()->updateInterpreters(PythonSettings::interpreters());
|
||||
aspect<InterpreterAspect>()->setDefaultInterpreter(
|
||||
interpreters.isEmpty() ? PythonSettings::defaultInterpreter() : interpreters.first());
|
||||
|
||||
auto scriptAspect = addAspect<MainScriptAspect>();
|
||||
scriptAspect->setSettingsKey("PythonEditor.RunConfiguation.Script");
|
||||
|
||||
Reference in New Issue
Block a user