Skip to content

How-to: Build a Plugin

Goal

Register external commands through Python entry points.

Step 1. Add entry point

[project.entry-points."sayer.commands"]
myplugin = mypackage.module:register_func

Step 2. Register commands

from sayer import command


def register_func():
    @command()
    def hello_plugin():
        print("hello from plugin")

Step 3. Install and run

pip install -e .
python app.py hello-plugin

Design Guidelines

  • Keep register_func lightweight.
  • Avoid side effects during import.
  • Treat plugin load failures as recoverable.