forked from qt-creator/qt-creator
Python: improve pyside tool detection
Look right next to the used python. For virtual env setups this should be a lot faster than asking pip for the installed files. Additionally this should work for pyside devenvs. Change-Id: I2a8cf6877636785453426c348cfac252645aa4e1 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -149,6 +149,13 @@ public:
|
|||||||
void updateExtraCompilers();
|
void updateExtraCompilers();
|
||||||
void currentInterpreterChanged();
|
void currentInterpreterChanged();
|
||||||
|
|
||||||
|
struct PySideTools
|
||||||
|
{
|
||||||
|
FilePath pySideProjectPath;
|
||||||
|
FilePath pySideUicPath;
|
||||||
|
};
|
||||||
|
void updateTools(const PySideTools &tools);
|
||||||
|
|
||||||
FilePath m_pySideUicPath;
|
FilePath m_pySideUicPath;
|
||||||
|
|
||||||
PythonInterpreterAspect *q;
|
PythonInterpreterAspect *q;
|
||||||
@@ -195,6 +202,14 @@ PythonInterpreterAspect::~PythonInterpreterAspect()
|
|||||||
|
|
||||||
void PythonInterpreterAspectPrivate::checkForPySide(const FilePath &python)
|
void PythonInterpreterAspectPrivate::checkForPySide(const FilePath &python)
|
||||||
{
|
{
|
||||||
|
PySideTools tools;
|
||||||
|
const FilePath dir = python.parentDir();
|
||||||
|
tools.pySideProjectPath = dir.pathAppended("pyside6-project").withExecutableSuffix();
|
||||||
|
tools.pySideUicPath = dir.pathAppended("pyside6-uic").withExecutableSuffix();
|
||||||
|
|
||||||
|
if (tools.pySideProjectPath.isExecutableFile() && tools.pySideUicPath.isExecutableFile())
|
||||||
|
updateTools(tools);
|
||||||
|
else
|
||||||
checkForPySide(python, "PySide6-Essentials");
|
checkForPySide(python, "PySide6-Essentials");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,24 +230,10 @@ void PythonInterpreterAspectPrivate::handlePySidePackageInfo(const PipPackageInf
|
|||||||
const FilePath &python,
|
const FilePath &python,
|
||||||
const QString &requestedPackageName)
|
const QString &requestedPackageName)
|
||||||
{
|
{
|
||||||
struct PythonTools
|
|
||||||
{
|
|
||||||
FilePath pySideProjectPath;
|
|
||||||
FilePath pySideUicPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
BuildStepList *buildSteps = nullptr;
|
|
||||||
if (Target *target = rc->target()) {
|
|
||||||
if (auto buildConfiguration = target->activeBuildConfiguration())
|
|
||||||
buildSteps = buildConfiguration->buildSteps();
|
|
||||||
}
|
|
||||||
if (!buildSteps)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto findPythonTools = [](const FilePaths &files,
|
const auto findPythonTools = [](const FilePaths &files,
|
||||||
const FilePath &location,
|
const FilePath &location,
|
||||||
const FilePath &python) -> PythonTools {
|
const FilePath &python) -> PySideTools {
|
||||||
PythonTools result;
|
PySideTools result;
|
||||||
const QString pySide6ProjectName
|
const QString pySide6ProjectName
|
||||||
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-project");
|
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-project");
|
||||||
const QString pySide6UicName
|
const QString pySide6UicName
|
||||||
@@ -253,18 +254,13 @@ void PythonInterpreterAspectPrivate::handlePySidePackageInfo(const PipPackageInf
|
|||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
PythonTools pythonTools = findPythonTools(pySideInfo.files, pySideInfo.location, python);
|
PySideTools tools = findPythonTools(pySideInfo.files, pySideInfo.location, python);
|
||||||
if (!pythonTools.pySideProjectPath.isExecutableFile() && requestedPackageName != "PySide6") {
|
if (!tools.pySideProjectPath.isExecutableFile() && requestedPackageName != "PySide6") {
|
||||||
checkForPySide(python, "PySide6");
|
checkForPySide(python, "PySide6");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pySideUicPath = pythonTools.pySideUicPath;
|
updateTools(tools);
|
||||||
|
|
||||||
updateExtraCompilers();
|
|
||||||
|
|
||||||
if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
|
|
||||||
pySideBuildStep->updatePySideProjectPath(pythonTools.pySideProjectPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonInterpreterAspectPrivate::currentInterpreterChanged()
|
void PythonInterpreterAspectPrivate::currentInterpreterChanged()
|
||||||
@@ -283,6 +279,22 @@ void PythonInterpreterAspectPrivate::currentInterpreterChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PythonInterpreterAspectPrivate::updateTools(const PySideTools &tools)
|
||||||
|
{
|
||||||
|
m_pySideUicPath = tools.pySideUicPath;
|
||||||
|
|
||||||
|
updateExtraCompilers();
|
||||||
|
|
||||||
|
if (Target *target = rc->target()) {
|
||||||
|
if (BuildConfiguration *buildConfiguration = target->activeBuildConfiguration()) {
|
||||||
|
if (BuildStepList *buildSteps = buildConfiguration->buildSteps()) {
|
||||||
|
if (auto buildStep = buildSteps->firstOfType<PySideBuildStep>())
|
||||||
|
buildStep->updatePySideProjectPath(tools.pySideProjectPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<PySideUicExtraCompiler *> PythonInterpreterAspect::extraCompilers() const
|
QList<PySideUicExtraCompiler *> PythonInterpreterAspect::extraCompilers() const
|
||||||
{
|
{
|
||||||
return d->m_extraCompilers;
|
return d->m_extraCompilers;
|
||||||
|
|||||||
Reference in New Issue
Block a user