mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
Merge pull request #12301 from jozsefsallai/master
Better Python path detection on Windows
This commit is contained in:
commit
eb0295197c
@ -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()) {
|
||||||
|
const QDir baseDir {path};
|
||||||
|
|
||||||
|
if (baseDir.exists("python3.exe")) {
|
||||||
found = true;
|
found = true;
|
||||||
path = QDir(path).filePath("python.exe");
|
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…
x
Reference in New Issue
Block a user