forked from qt-creator/qt-creator
Python: Limit detection to unique python
In case we are having symbolic links on python or its parent path(s) we added an interpreter for each of these. Resolve the python path explicitly and only add them if they are unique. Change-Id: I21b9d7d85e82c5ec3a18e182dfcde2b98936a8af Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -690,12 +690,15 @@ static QList<Interpreter> pythonsFromPath()
|
||||
"python[1-9].[1-9][0-9]",
|
||||
"python[1-9]"};
|
||||
const FilePaths dirs = Environment::systemEnvironment().path();
|
||||
QSet<FilePath> used;
|
||||
for (const FilePath &path : dirs) {
|
||||
const QDir dir(path.toString());
|
||||
for (const QFileInfo &fi : dir.entryInfoList(filters)) {
|
||||
const FilePath executable = Utils::FilePath::fromFileInfo(fi);
|
||||
if (executable.exists())
|
||||
const FilePath executable = FilePath::fromUserInput(fi.canonicalFilePath());
|
||||
if (!used.contains(executable) && executable.exists()) {
|
||||
used.insert(executable);
|
||||
pythons << createInterpreter(executable, "Python from Path");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user