377 for pluginName in self.__foundCoreModules: |
377 for pluginName in self.__foundCoreModules: |
378 # plug-in under development has priority |
378 # plug-in under development has priority |
379 if pluginName.startswith("PluginDocumentationSets"): |
379 if pluginName.startswith("PluginDocumentationSets"): |
380 self.loadPlugin(pluginName, self.pluginDirs["eric6"]) |
380 self.loadPlugin(pluginName, self.pluginDirs["eric6"]) |
381 |
381 |
382 def loadPlugin(self, name, directory, reload_=False): |
382 def loadPlugin(self, name, directory, reload_=False, install=False): |
383 """ |
383 """ |
384 Public method to load a plugin module. |
384 Public method to load a plugin module. |
385 |
385 |
386 Initially all modules are inactive. Modules that are requested on |
386 Initially all modules are inactive. Modules that are requested on |
387 demand are sorted out and are added to the on demand list. Some |
387 demand are sorted out and are added to the on demand list. Some |
388 basic validity checks are performed as well. Modules failing these |
388 basic validity checks are performed as well. Modules failing these |
389 checks are added to the failed modules list. |
389 checks are added to the failed modules list. |
390 |
390 |
391 @param name name of the module to be loaded (string) |
391 @param name name of the module to be loaded |
392 @param directory name of the plugin directory (string) |
392 @type str |
393 @param reload_ flag indicating to reload the module (boolean) |
393 @param directory name of the plugin directory |
|
394 @type str |
|
395 @param reload_ flag indicating to reload the module |
|
396 @type bool |
|
397 @param install flag indicating a load operation as part of an |
|
398 installation process |
|
399 @type bool |
394 @exception PluginLoadError raised to indicate an issue loading |
400 @exception PluginLoadError raised to indicate an issue loading |
395 the plug-in |
401 the plug-in |
396 """ |
402 """ |
397 try: |
403 try: |
398 fname = "{0}.py".format(os.path.join(directory, name)) |
404 fname = "{0}.py".format(os.path.join(directory, name)) |
420 raise PluginLoadError(name) |
426 raise PluginLoadError(name) |
421 else: |
427 else: |
422 self.__onDemandInactiveModules[name] = module |
428 self.__onDemandInactiveModules[name] = module |
423 module.eric6PluginModuleName = name |
429 module.eric6PluginModuleName = name |
424 module.eric6PluginModuleFilename = fname |
430 module.eric6PluginModuleFilename = fname |
425 if hasattr(module, "installDependencies"): |
431 if install and hasattr(module, "installDependencies"): |
426 # ask the module to install its dependencies |
432 # ask the module to install its dependencies |
427 module.installDependencies(self.pipInstall) |
433 module.installDependencies(self.pipInstall) |
428 self.__modulesCount += 1 |
434 self.__modulesCount += 1 |
429 if reload_: |
435 if reload_: |
430 importlib.reload(module) |
436 importlib.reload(module) |
1422 |
1428 |
1423 ######################################################################## |
1429 ######################################################################## |
1424 ## Methods to install a plug-in module dependency via pip |
1430 ## Methods to install a plug-in module dependency via pip |
1425 ######################################################################## |
1431 ######################################################################## |
1426 |
1432 |
1427 def pipInstall(self, packageName): |
1433 def pipInstall(self, packages): |
1428 """ |
1434 """ |
1429 Public method to install the given package via pip. |
1435 Public method to install the given package via pip. |
1430 |
1436 |
1431 @param packageName name of the package to be installed |
1437 @param packages list of packages to install |
1432 @type str |
1438 @type list of str |
1433 @return flag indicating a successful installation |
1439 """ |
1434 @rtype bool |
1440 try: |
1435 """ |
1441 pip = e5App().getObject("Pip") |
1436 # TODO: implement this |
1442 except KeyError: |
1437 return False |
1443 # Installation is performed via the plug-in installation script. |
|
1444 from PipInterface.Pip import Pip |
|
1445 pip = Pip(self) |
|
1446 pip.installPackages(packages, interpreter=sys.executable) |
1438 |
1447 |
1439 # |
1448 # |
1440 # eflag: noqa = M801 |
1449 # eflag: noqa = M801 |