diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index e5251384d2c..0a6abe2e043 100644 --- a/src/plugins/python/pythonsettings.cpp +++ b/src/plugins/python/pythonsettings.cpp @@ -653,17 +653,15 @@ static void addPythonsFromRegistry(QList &pythons) static void addPythonsFromPath(QList &pythons) { - const auto &env = Environment::systemEnvironment(); - if (HostOsInfo::isWindowsHost()) { - for (const FilePath &executable : env.findAllInPath("python")) { + for (const FilePath &executable : FilePath("python").searchAllInPath()) { // Windows creates empty redirector files that may interfere if (executable.toFileInfo().size() == 0) continue; if (executable.exists() && !alreadyRegistered(pythons, executable)) pythons << createInterpreter(executable, "Python from Path"); } - for (const FilePath &executable : env.findAllInPath("pythonw")) { + for (const FilePath &executable : FilePath("pythonw").searchAllInPath()) { if (executable.exists() && !alreadyRegistered(pythons, executable)) pythons << createInterpreter(executable, "Python from Path", "(Windowed)"); } @@ -672,7 +670,8 @@ static void addPythonsFromPath(QList &pythons) "python[1-9].[0-9]", "python[1-9].[1-9][0-9]", "python[1-9]"}; - for (const FilePath &path : env.path()) { + const FilePaths dirs = Environment::systemEnvironment().path(); + for (const FilePath &path : dirs) { const QDir dir(path.toString()); for (const QFileInfo &fi : dir.entryInfoList(filters)) { const FilePath executable = Utils::FilePath::fromFileInfo(fi); @@ -685,9 +684,9 @@ static void addPythonsFromPath(QList &pythons) static QString idForPythonFromPath(const QList &pythons) { - FilePath pythonFromPath = Environment::systemEnvironment().searchInPath("python3"); + FilePath pythonFromPath = FilePath("python3").searchInPath(); if (pythonFromPath.isEmpty()) - pythonFromPath = Environment::systemEnvironment().searchInPath("python"); + pythonFromPath = FilePath("python").searchInPath(); if (pythonFromPath.isEmpty()) return {}; const Interpreter &defaultInterpreter diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index bf3f683dd13..43d23a256bc 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -36,7 +36,7 @@ FilePath detectPython(const FilePath &documentPath) if (!project) project = ProjectManager::startupProject(); - Environment env = Environment::systemEnvironment(); + FilePaths dirs = Environment::systemEnvironment().path(); if (project) { if (auto target = project->activeTarget()) { @@ -44,7 +44,7 @@ FilePath detectPython(const FilePath &documentPath) if (auto interpreter = runConfig->aspect()) return interpreter->currentInterpreter().command; if (auto environmentAspect = runConfig->aspect()) - env = environmentAspect->environment(); + dirs = environmentAspect->environment().path(); } } } @@ -62,8 +62,9 @@ FilePath detectPython(const FilePath &documentPath) if (defaultInterpreter.exists()) return defaultInterpreter; - auto pythonFromPath = [=](const QString toCheck) { - for (const FilePath &python : env.findAllInPath(toCheck)) { + auto pythonFromPath = [dirs](const FilePath &toCheck) { + const FilePaths found = toCheck.searchAllInDirectories(dirs); + for (const FilePath &python : found) { // Windows creates empty redirector files that may interfere if (python.exists() && python.osType() == OsTypeWindows && python.fileSize() != 0) return python;