aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonrunconfiguration.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2023-09-26 09:39:32 +0200
committerDavid Schulz <david.schulz@qt.io>2023-09-29 09:19:52 +0000
commited6595a66ec654e3cdb12f4a4863425ab43ffb71 (patch)
treeaa9a565925a55b634351cc8e501d6c00fe85d48a /src/plugins/python/pythonrunconfiguration.cpp
parent80633a59aabca94e52e473837164203041e72c6e (diff)
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>
Diffstat (limited to 'src/plugins/python/pythonrunconfiguration.cpp')
-rw-r--r--src/plugins/python/pythonrunconfiguration.cpp62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp
index 05366abff24..12141ba1a93 100644
--- a/src/plugins/python/pythonrunconfiguration.cpp
+++ b/src/plugins/python/pythonrunconfiguration.cpp
@@ -149,6 +149,13 @@ public:
void updateExtraCompilers();
void currentInterpreterChanged();
+ struct PySideTools
+ {
+ FilePath pySideProjectPath;
+ FilePath pySideUicPath;
+ };
+ void updateTools(const PySideTools &tools);
+
FilePath m_pySideUicPath;
PythonInterpreterAspect *q;
@@ -195,7 +202,15 @@ PythonInterpreterAspect::~PythonInterpreterAspect()
void PythonInterpreterAspectPrivate::checkForPySide(const FilePath &python)
{
- checkForPySide(python, "PySide6-Essentials");
+ 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");
}
void PythonInterpreterAspectPrivate::checkForPySide(const FilePath &python,
@@ -215,24 +230,10 @@ void PythonInterpreterAspectPrivate::handlePySidePackageInfo(const PipPackageInf
const FilePath &python,
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 FilePath &location,
- const FilePath &python) -> PythonTools {
- PythonTools result;
+ const FilePath &python) -> PySideTools {
+ PySideTools result;
const QString pySide6ProjectName
= OsSpecificAspects::withExecutableSuffix(python.osType(), "pyside6-project");
const QString pySide6UicName
@@ -253,18 +254,13 @@ void PythonInterpreterAspectPrivate::handlePySidePackageInfo(const PipPackageInf
return {};
};
- PythonTools pythonTools = findPythonTools(pySideInfo.files, pySideInfo.location, python);
- if (!pythonTools.pySideProjectPath.isExecutableFile() && requestedPackageName != "PySide6") {
+ PySideTools tools = findPythonTools(pySideInfo.files, pySideInfo.location, python);
+ if (!tools.pySideProjectPath.isExecutableFile() && requestedPackageName != "PySide6") {
checkForPySide(python, "PySide6");
return;
}
- m_pySideUicPath = pythonTools.pySideUicPath;
-
- updateExtraCompilers();
-
- if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
- pySideBuildStep->updatePySideProjectPath(pythonTools.pySideProjectPath);
+ updateTools(tools);
}
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
{
return d->m_extraCompilers;