From 3b8b247f88f3a97bdd69f6ea058ed439f9b8648b Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 16 Jun 2022 15:09:39 +0200 Subject: Python: ignore windows store redirectors Change-Id: Ife5c13549d73156550a7ce4b5436f1e5a19503fa Reviewed-by: Christian Stenger --- src/plugins/python/pythonutils.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/plugins/python/pythonutils.cpp') diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 08c8750c21..ebc2a695f7 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -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 fromPath3 = pythonFromPath("python3"); + if (fromPath3.exists()) + return fromPath3; - const FilePath pythonFromPath = env.searchInPath("python"); - if (pythonFromPath.exists()) - return pythonFromPath; + const FilePath fromPath = pythonFromPath("python"); + if (fromPath.exists()) + return fromPath; return PythonSettings::interpreters().value(0).command; } -- cgit v1.2.1