Skip to content
Permalink
Browse files
[plugins] Add support for experimental dependencies
  • Loading branch information
gacarrillor authored and github-actions committed Nov 4, 2021
1 parent 20563d6 commit 080812798c2d2cb66161dda8f913539a4c87eca0
Showing with 27 additions and 6 deletions.
  1. +4 −4 python/pyplugin_installer/installer.py
  2. +19 −1 python/pyplugin_installer/plugindependencies.py
  3. +4 −1 python/pyplugin_installer/qgsplugindependenciesdialog.py
@@ -682,17 +682,17 @@ def processDependencies(self, plugin_id):
dlg = QgsPluginDependenciesDialog(plugin_id, to_install, to_upgrade, not_found)
if dlg.exec_() == QgsPluginDependenciesDialog.Accepted:
actions = dlg.actions()
for dependency_plugin_id, action in actions.items():
for dependency_plugin_id, action_data in actions.items():
try:
self.installPlugin(dependency_plugin_id)
if action == 'install':
self.installPlugin(dependency_plugin_id, stable=action_data['use_stable_version'])
if action_data['action'] == 'install':
iface.pluginManagerInterface().pushMessage(self.tr("Plugin dependency <b>%s</b> successfully installed") %
dependency_plugin_id, Qgis.Info)
else:
iface.pluginManagerInterface().pushMessage(self.tr("Plugin dependency <b>%s</b> successfully upgraded") %
dependency_plugin_id, Qgis.Info)
except Exception as ex:
if action == 'install':
if action_data['action'] == 'install':
iface.pluginManagerInterface().pushMessage(self.tr("Error installing plugin dependency <b>%s</b>: %s") %
(dependency_plugin_id, ex), Qgis.Warning)
else:
@@ -79,8 +79,26 @@ def find_dependencies(plugin_id, plugin_data=None, plugin_deps=None, installed_p
"version_installed": installed_plugins.get(name, None),
"version_required": version_required,
"version_available": plugin_data[p_id].get('version_available', None),
"use_stable_version": True, # Prefer stable by default
"action": None,
})
version_available_stable = plugin_data[p_id].get('version_available_stable', None)
version_available_experimental = plugin_data[p_id].get('version_available_experimental', None)

if version_required is not None and version_required == version_available_stable:
affected_plugin["version_available"] = version_available_stable
affected_plugin["use_stable_version"] = True
elif version_required is not None and version_required == version_available_experimental:
affected_plugin["version_available"] = version_available_experimental
affected_plugin["use_stable_version"] = False
elif version_required is None:
if version_available_stable: # None if not found, "" if not offered
# Prefer the stable version, if any
affected_plugin["version_available"] = version_available_stable
affected_plugin["use_stable_version"] = True
else: # The only available version is experimental
affected_plugin["version_available"] = version_available_experimental
affected_plugin["use_stable_version"] = False

# Install is needed
if name not in installed_plugins:
@@ -95,7 +113,7 @@ def find_dependencies(plugin_id, plugin_data=None, plugin_deps=None, installed_p
else:
continue

if affected_plugin['version_required'] == affected_plugin['version_available'] or affected_plugin['version_required'] is None:
if version_required == affected_plugin['version_available'] or version_required is None:
destination_list.update({name: affected_plugin})
else:
affected_plugin['error'] = 'unavailable {}'.format(affected_plugin['action'])
@@ -60,6 +60,7 @@ def _make_row(data, i, name):
widget = QtWidgets.QLabel("<b>%s</b>" % name)
widget.p_id = data['id']
widget.action = data['action']
widget.use_stable_version = data['use_stable_version']
self.pluginList.setCellWidget(i, 0, widget)
widget = QtWidgets.QTableWidgetItem(_display(data['version_installed']))
widget.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
@@ -106,7 +107,9 @@ def accept(self):
for i in range(self.pluginList.rowCount()):
try:
if self.pluginList.cellWidget(i, 4).isChecked():
self.__actions[self.pluginList.cellWidget(i, 0).p_id] = self.pluginList.cellWidget(i, 0).action
self.__actions[self.pluginList.cellWidget(i, 0).p_id] = {
'action': self.pluginList.cellWidget(i, 0).action,
'use_stable_version': self.pluginList.cellWidget(i, 0).use_stable_version}
except:
pass
super().accept()

0 comments on commit 0808127

Please sign in to comment.