mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 17:26:21 +03:00
Detect python3 executable on Windows
This commit is contained in:
parent
5049b76b40
commit
f9564564f8
1 changed files with 19 additions and 12 deletions
|
@ -190,9 +190,17 @@ namespace
|
||||||
path = getRegValue(hkInstallPath);
|
path = getRegValue(hkInstallPath);
|
||||||
::RegCloseKey(hkInstallPath);
|
::RegCloseKey(hkInstallPath);
|
||||||
|
|
||||||
if (!path.isEmpty() && QDir(path).exists("python.exe")) {
|
if (!path.isEmpty()) {
|
||||||
found = true;
|
const QDir baseDir {path};
|
||||||
path = QDir(path).filePath("python.exe");
|
|
||||||
|
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
|
||||||
// Fallback: Detect python from default locations
|
// Fallback: Detect python from default locations
|
||||||
const QFileInfoList dirs = QDir("C:/").entryInfoList({"Python*"}, QDir::Dirs, (QDir::Name | QDir::Reversed));
|
const QFileInfoList dirs = QDir("C:/").entryInfoList({"Python*"}, QDir::Dirs, (QDir::Name | QDir::Reversed));
|
||||||
for (const QFileInfo &info : dirs) {
|
for (const QFileInfo &info : dirs) {
|
||||||
const QString path {info.absolutePath() + "/python.exe"};
|
const QString py3Path {info.absolutePath() + "/python3.exe"};
|
||||||
if (QFile::exists(path))
|
if (QFile::exists(py3Path))
|
||||||
return path;
|
return py3Path;
|
||||||
|
|
||||||
|
const QString pyPath {info.absolutePath() + "/python.exe"};
|
||||||
|
if (QFile::exists(pyPath))
|
||||||
|
return pyPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -247,14 +259,9 @@ PythonInfo Utils::ForeignApps::pythonInfo()
|
||||||
{
|
{
|
||||||
static PythonInfo pyInfo;
|
static PythonInfo pyInfo;
|
||||||
if (!pyInfo.isValid()) {
|
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))
|
if (testPythonInstallation("python3", pyInfo))
|
||||||
return pyInfo;
|
return pyInfo;
|
||||||
#endif
|
|
||||||
// Look for "python" in Windows and in UNIX if "python3" is
|
|
||||||
// not detected.
|
|
||||||
if (testPythonInstallation("python", pyInfo))
|
if (testPythonInstallation("python", pyInfo))
|
||||||
return pyInfo;
|
return pyInfo;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue