Python: ignore windows store redirectors

Change-Id: Ife5c13549d73156550a7ce4b5436f1e5a19503fa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-06-16 15:09:39 +02:00
parent 498418bbc9
commit 3b8b247f88

View File

@@ -74,13 +74,22 @@ FilePath detectPython(const FilePath &documentPath)
if (defaultInterpreter.exists())
return defaultInterpreter;
const FilePath python3FromPath = env.searchInPath("python3");
if (python3FromPath.exists())
return python3FromPath;
auto pythonFromPath = [=](const QString toCheck) {
for (const FilePath &python : env.findAllInPath(toCheck)) {
// Windows creates empty redirector files that may interfere
if (python.exists() && python.osType() == OsTypeWindows && python.fileSize() != 0)
return python;
}
return FilePath();
};
const FilePath pythonFromPath = env.searchInPath("python");
if (pythonFromPath.exists())
return pythonFromPath;
const FilePath fromPath3 = pythonFromPath("python3");
if (fromPath3.exists())
return fromPath3;
const FilePath fromPath = pythonFromPath("python");
if (fromPath.exists())
return fromPath;
return PythonSettings::interpreters().value(0).command;
}