forked from qt-creator/qt-creator
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:
@@ -206,51 +206,56 @@ PythonRunConfiguration::~PythonRunConfiguration()
|
|||||||
qDeleteAll(m_extraCompilers);
|
qDeleteAll(m_extraCompilers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PythonTools
|
||||||
|
{
|
||||||
|
FilePath pySideProjectPath;
|
||||||
|
FilePath pySideUicPath;
|
||||||
|
};
|
||||||
|
|
||||||
void PythonRunConfiguration::checkForPySide(const FilePath &python)
|
void PythonRunConfiguration::checkForPySide(const FilePath &python)
|
||||||
{
|
{
|
||||||
BuildStepList *buildSteps = target()->activeBuildConfiguration()->buildSteps();
|
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)) {
|
const auto findPythonTools = [](const FilePaths &files,
|
||||||
if (file.fileName() == HostOsInfo::withExecutableSuffix("pyside6-project")) {
|
const FilePath &location,
|
||||||
pySideProjectPath = info.location.resolvePath(file);
|
const FilePath &python) -> PythonTools {
|
||||||
pySideProjectPath = pySideProjectPath.cleanPath();
|
PythonTools result;
|
||||||
if (!m_pySideUicPath.isEmpty())
|
const QString pySide6ProjectName
|
||||||
break;
|
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-project");
|
||||||
} else if (file.fileName() == HostOsInfo::withExecutableSuffix("pyside6-uic")) {
|
const QString pySide6UicName
|
||||||
m_pySideUicPath = info.location.resolvePath(file);
|
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-uic");
|
||||||
m_pySideUicPath = m_pySideUicPath.cleanPath();
|
for (const FilePath &file : files) {
|
||||||
if (!pySideProjectPath.isEmpty())
|
if (file.fileName() == pySide6ProjectName) {
|
||||||
break;
|
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 {};
|
||||||
// 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())
|
const PipPackage pySide6EssentialPackage("PySide6-Essentials");
|
||||||
pySideProjectPath = userInstalledPySideTool("pyside6-project");
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pySideUicPath = pythonTools.pySideUicPath;
|
||||||
|
|
||||||
updateExtraCompilers();
|
updateExtraCompilers();
|
||||||
|
|
||||||
if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
|
if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
|
||||||
pySideBuildStep->updatePySideProjectPath(pySideProjectPath);
|
pySideBuildStep->updatePySideProjectPath(pythonTools.pySideProjectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonRunConfiguration::currentInterpreterChanged()
|
void PythonRunConfiguration::currentInterpreterChanged()
|
||||||
|
Reference in New Issue
Block a user