Prepared the plugin manager to install plug-in dependecies.

Thu, 06 May 2021 19:45:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 06 May 2021 19:45:45 +0200
changeset 8293
cad568796748
parent 8292
54b48d756b0a
child 8294
cb4e5bbf3a2c

Prepared the plugin manager to install plug-in dependecies.

eric6/Documentation/Source/eric6.PluginManager.PluginManager.html file | annotate | diff | comparison | revisions
eric6/PluginManager/PluginInstallDialog.py file | annotate | diff | comparison | revisions
eric6/PluginManager/PluginManager.py file | annotate | diff | comparison | revisions
--- a/eric6/Documentation/Source/eric6.PluginManager.PluginManager.html	Wed May 05 19:59:47 2021 +0200
+++ b/eric6/Documentation/Source/eric6.PluginManager.PluginManager.html	Thu May 06 19:45:45 2021 +0200
@@ -266,6 +266,10 @@
 <td>Public method to load a plugin module.</td>
 </tr>
 <tr>
+<td><a href="#PluginManager.pipInstall">pipInstall</a></td>
+<td>Public method to install the given package via pip.</td>
+</tr>
+<tr>
 <td><a href="#PluginManager.preferencesChanged">preferencesChanged</a></td>
 <td>Public slot to react to changes in configuration.</td>
 </tr>
@@ -1092,7 +1096,7 @@
 </dl>
 <a NAME="PluginManager.loadPlugin" ID="PluginManager.loadPlugin"></a>
 <h4>PluginManager.loadPlugin</h4>
-<b>loadPlugin</b>(<i>name, directory, reload_=False</i>)
+<b>loadPlugin</b>(<i>name, directory, reload_=False, install=False</i>)
 
 <p>
         Public method to load a plugin module.
@@ -1105,17 +1109,22 @@
 </p>
 <dl>
 
-<dt><i>name</i></dt>
+<dt><i>name</i> (str)</dt>
 <dd>
-name of the module to be loaded (string)
+name of the module to be loaded
 </dd>
-<dt><i>directory</i></dt>
+<dt><i>directory</i> (str)</dt>
 <dd>
-name of the plugin directory (string)
+name of the plugin directory
 </dd>
-<dt><i>reload_</i></dt>
+<dt><i>reload_</i> (bool)</dt>
 <dd>
-flag indicating to reload the module (boolean)
+flag indicating to reload the module
+</dd>
+<dt><i>install</i> (bool)</dt>
+<dd>
+flag indicating a load operation as part of an
+            installation process
 </dd>
 </dl>
 <dl>
@@ -1126,6 +1135,20 @@
             the plug-in
 </dd>
 </dl>
+<a NAME="PluginManager.pipInstall" ID="PluginManager.pipInstall"></a>
+<h4>PluginManager.pipInstall</h4>
+<b>pipInstall</b>(<i>packages</i>)
+
+<p>
+        Public method to install the given package via pip.
+</p>
+<dl>
+
+<dt><i>packages</i> (list of str)</dt>
+<dd>
+list of packages to install
+</dd>
+</dl>
 <a NAME="PluginManager.preferencesChanged" ID="PluginManager.preferencesChanged"></a>
 <h4>PluginManager.preferencesChanged</h4>
 <b>preferencesChanged</b>(<i></i>)
--- a/eric6/PluginManager/PluginInstallDialog.py	Wed May 05 19:59:47 2021 +0200
+++ b/eric6/PluginManager/PluginInstallDialog.py	Thu May 06 19:45:45 2021 +0200
@@ -497,12 +497,11 @@
             compileall.compile_file(files, quiet=True)
             os.path.join_unicode = True
         
-        if not self.__external:
             # now load and activate the plugin
-            self.__pluginManager.loadPlugin(installedPluginName, destination,
-                                            reload_)
-            if activatePlugin:
-                self.__pluginManager.activatePlugin(installedPluginName)
+        self.__pluginManager.loadPlugin(
+            installedPluginName, destination, reload_=reload_, install=True)
+        if activatePlugin and not self.__external:
+            self.__pluginManager.activatePlugin(installedPluginName)
         
         return True, "", needsRestart
     
--- a/eric6/PluginManager/PluginManager.py	Wed May 05 19:59:47 2021 +0200
+++ b/eric6/PluginManager/PluginManager.py	Thu May 06 19:45:45 2021 +0200
@@ -379,7 +379,7 @@
             if pluginName.startswith("PluginDocumentationSets"):
                 self.loadPlugin(pluginName, self.pluginDirs["eric6"])
     
-    def loadPlugin(self, name, directory, reload_=False):
+    def loadPlugin(self, name, directory, reload_=False, install=False):
         """
         Public method to load a plugin module.
         
@@ -388,9 +388,15 @@
         basic validity checks are performed as well. Modules failing these
         checks are added to the failed modules list.
         
-        @param name name of the module to be loaded (string)
-        @param directory name of the plugin directory (string)
-        @param reload_ flag indicating to reload the module (boolean)
+        @param name name of the module to be loaded
+        @type str
+        @param directory name of the plugin directory
+        @type str
+        @param reload_ flag indicating to reload the module
+        @type bool
+        @param install flag indicating a load operation as part of an
+            installation process
+        @type bool
         @exception PluginLoadError raised to indicate an issue loading
             the plug-in
         """
@@ -422,7 +428,7 @@
                     self.__onDemandInactiveModules[name] = module
             module.eric6PluginModuleName = name
             module.eric6PluginModuleFilename = fname
-            if hasattr(module, "installDependencies"):
+            if install and hasattr(module, "installDependencies"):
                 # ask the module to install its dependencies
                 module.installDependencies(self.pipInstall)
             self.__modulesCount += 1
@@ -1424,17 +1430,20 @@
     ## Methods to install a plug-in module dependency via pip
     ########################################################################
     
-    def pipInstall(self, packageName):
+    def pipInstall(self, packages):
         """
         Public method to install the given package via pip.
         
-        @param packageName name of the package to be installed
-        @type str
-        @return flag indicating a successful installation
-        @rtype bool
+        @param packages list of packages to install
+        @type list of str
         """
-        # TODO: implement this
-        return False
+        try:
+            pip = e5App().getObject("Pip")
+        except KeyError:
+            # Installation is performed via the plug-in installation script.
+            from PipInterface.Pip import Pip
+            pip = Pip(self)
+        pip.installPackages(packages, interpreter=sys.executable)
 
 #
 # eflag: noqa = M801

eric ide

mercurial