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:
Christian Stenger
2023-11-14 11:18:47 +01:00
parent 737c9ce41e
commit 4f7865eb4d

View File

@@ -690,15 +690,18 @@ 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");
}
}
}
}
return pythons;
}