Python: fix PySide project tool detection

The tool moved to the PySide6-Essentials module.

Change-Id: I204d2025bc51b6c5cffe82cba66878d077f03b72
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-10-18 12:07:24 +02:00
parent 534c312d27
commit af7b0802a8

View File

@@ -206,51 +206,56 @@ PythonRunConfiguration::~PythonRunConfiguration()
qDeleteAll(m_extraCompilers);
}
struct PythonTools
{
FilePath pySideProjectPath;
FilePath pySideUicPath;
};
void PythonRunConfiguration::checkForPySide(const FilePath &python)
{
BuildStepList *buildSteps = target()->activeBuildConfiguration()->buildSteps();
FilePath pySideProjectPath;
m_pySideUicPath.clear();
const PipPackage pySide6Package("PySide6");
const PipPackageInfo info = pySide6Package.info(python);
for (const FilePath &file : std::as_const(info.files)) {
if (file.fileName() == HostOsInfo::withExecutableSuffix("pyside6-project")) {
pySideProjectPath = info.location.resolvePath(file);
pySideProjectPath = pySideProjectPath.cleanPath();
if (!m_pySideUicPath.isEmpty())
break;
} else if (file.fileName() == HostOsInfo::withExecutableSuffix("pyside6-uic")) {
m_pySideUicPath = info.location.resolvePath(file);
m_pySideUicPath = m_pySideUicPath.cleanPath();
if (!pySideProjectPath.isEmpty())
break;
const auto findPythonTools = [](const FilePaths &files,
const FilePath &location,
const FilePath &python) -> PythonTools {
PythonTools result;
const QString pySide6ProjectName
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-project");
const QString pySide6UicName
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-uic");
for (const FilePath &file : files) {
if (file.fileName() == pySide6ProjectName) {
result.pySideProjectPath = location.resolvePath(file).onDevice(python);
result.pySideProjectPath = result.pySideProjectPath.cleanPath();
if (!result.pySideUicPath.isEmpty())
return result;
} else if (file.fileName() == pySide6UicName) {
result.pySideUicPath = location.resolvePath(file).onDevice(python);
result.pySideUicPath = result.pySideUicPath.cleanPath();
if (!result.pySideProjectPath.isEmpty())
return result;
}
}
return {};
};
const PipPackage pySide6EssentialPackage("PySide6-Essentials");
PipPackageInfo info = pySide6EssentialPackage.info(python);
PythonTools pythonTools = findPythonTools(info.files, info.location, python);
if (!pythonTools.pySideProjectPath.isExecutableFile()) {
const PipPackage pySide6Package("PySide6");
info = pySide6Package.info(python);
pythonTools = findPythonTools(info.files, info.location, python);
}
// Workaround that pip might return an incomplete file list on windows
if (HostOsInfo::isWindowsHost() && !python.needsDevice()
&& !info.location.isEmpty() && m_pySideUicPath.isEmpty()) {
// Scripts is next to the site-packages install dir for user installations
FilePath scripts = info.location.parentDir().pathAppended("Scripts");
if (!scripts.exists()) {
// in global/venv installations Scripts is next to Lib/site-packages
scripts = info.location.parentDir().parentDir().pathAppended("Scripts");
}
auto userInstalledPySideTool = [&](const QString &toolName) {
const FilePath tool = scripts.pathAppended(HostOsInfo::withExecutableSuffix(toolName));
return tool.isExecutableFile() ? tool : FilePath();
};
m_pySideUicPath = userInstalledPySideTool("pyside6-uic");
if (pySideProjectPath.isEmpty())
pySideProjectPath = userInstalledPySideTool("pyside6-project");
}
m_pySideUicPath = pythonTools.pySideUicPath;
updateExtraCompilers();
if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
pySideBuildStep->updatePySideProjectPath(pySideProjectPath);
pySideBuildStep->updatePySideProjectPath(pythonTools.pySideProjectPath);
}
void PythonRunConfiguration::currentInterpreterChanged()