napari Plugin Engine v2 (npe2)

0.8.2 · active · verified Fri Apr 17

npe2 (napari plugin engine v2) is the modern, robust plugin system for napari. It facilitates explicit plugin discovery and contribution management through manifest files and package entry points, aiming for better isolation, explicit dependency management, and improved testability compared to its predecessor. The current version is 0.8.2, and it follows the napari release cycle, with frequent updates during active development phases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the npe2 PluginManager, discover available plugins (including npe1 plugins), and then inspect the contributions provided by a specific plugin. It shows how the engine itself can be used to query the plugin ecosystem.

from npe2 import PluginManager

pm = PluginManager.instance() # Get the singleton PluginManager instance

# Discover all plugins, including older npe1 plugins if present
pm.discover(include_npe1=True)

print(f"Discovered {len(pm.plugins)} plugin packages.")

# Example: List contributions from a specific plugin (e.g., 'napari-svg')
# This assumes 'napari-svg' is installed and has contributions
if "napari-svg" in pm.plugins:
    print(f"\nContributions from napari-svg:")
    for contribution_type in pm.get_plugin_contributions("napari-svg"):
        contributions = pm.get_plugin_contributions("napari-svg")[contribution_type]
        if contributions:
            print(f"  {contribution_type}: {list(contributions.keys())}")
else:
    print("\nnapari-svg not found or has no contributions. Try another installed plugin.")

view raw JSON →