def test_plugin_meta( tmp_path, add_specification, test_plugin_manager, app_good_plugin, good_entrypoint_plugin, double_convention_plugin, ): test_plugin_manager.discover_entry_point = 'app.plugin' test_plugin_manager.discover_prefix = 'app_' with temp_path_additions(tmp_path): cnt, err = test_plugin_manager.discover() assert set(test_plugin_manager.plugins) == { 'double_a', 'double_b', 'good_entry', 'app_good_plugin', } versions = { 'double_a': '3.2.1', 'double_b': '3.2.1', 'good_entry': '1.2.3', 'app_good_plugin': '', } for name, plug in test_plugin_manager.plugins.items(): assert versions[name] == get_version(plug) if name == 'app_good_plugin': # this one doesn't have any metadata.. but it will have plugin_name assert standard_metadata(plug) == {} else: assert get_version(plug) == standard_metadata(plug).get( 'version')
def refresh(self): self.installed_list.clear() self.available_list.clear() # fetch installed from ...plugins import plugin_manager plugin_manager.discover() # since they might not be loaded yet already_installed = set() for plugin_name, mod_name, distname in plugin_manager.iter_available(): # not showing these in the plugin dialog if plugin_name in ('napari_plugin_engine', ): continue if distname: already_installed.add(distname) meta = standard_metadata(distname) else: meta = {} self.installed_list.addItem( ProjectInfo( normalized_name(distname or ''), meta.get('version', ''), meta.get('url', ''), meta.get('summary', ''), meta.get('author', ''), meta.get('license', ''), ), plugin_name=plugin_name, enabled=plugin_name in plugin_manager.plugins, ) # self.v_splitter.setSizes([70 * self.installed_list.count(), 10, 10]) # fetch available plugins self.worker = create_worker(iter_napari_plugin_info) def _handle_yield(project_info): if project_info.name in already_installed: self.installed_list.tag_outdated(project_info) else: self.available_list.addItem(project_info) self.worker.yielded.connect(_handle_yield) self.worker.finished.connect(self.working_indicator.hide) self.worker.finished.connect(self._update_count_in_label) self.worker.start()
def _add_to_installed(distname, enabled, npe_version=1): if distname: meta = standard_metadata(distname) if len(meta) == 0: # will not add builtins. return self.already_installed.add(distname) else: meta = {} self.installed_list.addItem( ProjectInfo( normalized_name(distname or ''), meta.get('version', ''), meta.get('url', ''), meta.get('summary', ''), meta.get('author', ''), meta.get('license', ''), ), installed=True, enabled=enabled, npe_version=npe_version, )