Skip to content

Commit 7d59424

Browse files
committed
Add support for dependency check while installing a plugin.
Rationale: Since the installer has already loaded the original qgis.utils.loadPlugin when QPIP gets loaded, monkey patching qgis.utils.loadPlugin is not enough. We need to monkey patch also installer.loadPlugin as well.
1 parent e272291 commit 7d59424

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

a00_qpip/plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pkg_resources import DistributionNotFound, VersionConflict
1212
from qgis.core import QgsApplication, QgsSettings
1313
from qgis.PyQt.QtWidgets import QAction
14+
from pyplugin_installer import installer
1415

1516
from .ui import MainDialog
1617
from .utils import Lib, Req, icon, log, run_cmd
@@ -54,10 +55,11 @@ def __init__(self, iface, plugin_path=None):
5455

5556
sys.path_importer_cache.clear()
5657

57-
# Monkey patch qgis.utils
58-
log("Applying monkey patch to qgis.utils")
58+
# Monkey patch qgis.utils and installer
59+
log("Applying monkey patch to qgis.utils and installer")
5960
self._original_loadPlugin = qgis.utils.loadPlugin
6061
qgis.utils.loadPlugin = self.patched_load_plugin
62+
installer.loadPlugin = self.patched_load_plugin
6163

6264
self.iface.initializationCompleted.connect(self.initComplete)
6365

@@ -87,8 +89,9 @@ def unload(self):
8789
self.iface.removePluginMenu("QPIP", self.show_folder_action)
8890

8991
# Remove monkey patch
90-
log("Unapplying monkey patch to qgis.utils")
92+
log("Unapplying monkey patch to qgis.utils and installer")
9193
qgis.utils.loadPlugin = self._original_loadPlugin
94+
installer.loadPlugin = self._original_loadPlugin
9295

9396
# Remove path alterations
9497
if self.site_packages_path in sys.path:

0 commit comments

Comments
 (0)