Browse Source

Merge pull request #12301 from jozsefsallai/master

Better Python path detection on Windows
adaptive-webui-19844
Vladimir Golovnev 5 years ago committed by GitHub
parent
commit
eb0295197c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      src/base/utils/foreignapps.cpp

31
src/base/utils/foreignapps.cpp

@ -190,9 +190,17 @@ namespace @@ -190,9 +190,17 @@ namespace
path = getRegValue(hkInstallPath);
::RegCloseKey(hkInstallPath);
if (!path.isEmpty() && QDir(path).exists("python.exe")) {
found = true;
path = QDir(path).filePath("python.exe");
if (!path.isEmpty()) {
const QDir baseDir {path};
if (baseDir.exists("python3.exe")) {
found = true;
path = baseDir.filePath("python3.exe");
}
else if (baseDir.exists("python.exe")) {
found = true;
path = baseDir.filePath("python.exe");
}
}
}
}
@ -223,9 +231,13 @@ namespace @@ -223,9 +231,13 @@ namespace
// Fallback: Detect python from default locations
const QFileInfoList dirs = QDir("C:/").entryInfoList({"Python*"}, QDir::Dirs, (QDir::Name | QDir::Reversed));
for (const QFileInfo &info : dirs) {
const QString path {info.absolutePath() + "/python.exe"};
if (QFile::exists(path))
return path;
const QString py3Path {info.absolutePath() + "/python3.exe"};
if (QFile::exists(py3Path))
return py3Path;
const QString pyPath {info.absolutePath() + "/python.exe"};
if (QFile::exists(pyPath))
return pyPath;
}
return {};
@ -247,14 +259,9 @@ PythonInfo Utils::ForeignApps::pythonInfo() @@ -247,14 +259,9 @@ PythonInfo Utils::ForeignApps::pythonInfo()
{
static PythonInfo pyInfo;
if (!pyInfo.isValid()) {
#if defined(Q_OS_UNIX)
// On Unix-Like systems python3 should always exist
// https://www.python.org/dev/peps/pep-0394/
if (testPythonInstallation("python3", pyInfo))
return pyInfo;
#endif
// Look for "python" in Windows and in UNIX if "python3" is
// not detected.
if (testPythonInstallation("python", pyInfo))
return pyInfo;

Loading…
Cancel
Save