def _load_plugin(self, type_name, entrypoint: entrypoints.EntryPoint): # if the entrypoint was already loaded into cache and queued, do nothing if self._load_cache[type_name].get(entrypoint.name, None): return try: # Load the entrypoint (unless already cached), cache it, and put it on the instantiate queue msg.logMessage( f'Loading entrypoint {entrypoint.name} from module: {entrypoint.module_name}' ) with load_timer() as elapsed: plugin_class = self._load_cache[type_name][entrypoint.name] = \ self._load_cache[type_name].get(entrypoint.name, None) or entrypoint.load() except (Exception, SystemError) as ex: msg.logMessage( f"Unable to load {entrypoint.name} plugin from module: {entrypoint.module_name}", msg.ERROR) msg.logError(ex) msg.notifyMessage( repr(ex), title= f'An error occurred while starting the "{entrypoint.name}" plugin.', level=msg.CRITICAL) else: msg.logMessage( f"{int(elapsed() * 1000)} ms elapsed while loading {entrypoint.name}", level=msg.INFO) self._instantiate_queue.put((type_name, entrypoint, plugin_class))
def _load_plugin_entrypoint(self, entrypoint: entrypoints.EntryPoint) -> None: logger.debug(f"Loading the {entrypoint.name} plugin") plugin = entrypoint.load() if not issubclass(plugin, (Plugin, ApplicationPlugin)): raise ValueError( "The Poetry plugin must be an instance of Plugin or ApplicationPlugin" ) self.add_plugin(plugin())
def load(cls, entry_point: EntryPoint) -> "SectionPlugin": """ Load a plugin from a pre-parsed entry point Parses the following options: ``required`` If present implies ``required=True``. ``before=other`` This plugin must be processed before ``other``. ``after=other`` This plugin must be processed after ``other``. """ digest = entry_point.load() requirements = getattr(digest, "__requirements__", PluginRequirements()) if entry_point.extras: raise ValueError( f"SectionPlugin entry point '{entry_point.name}':" f" extras are no longer supported" ) return cls(section=entry_point.name, digest=digest, requirements=requirements)