plugin development best practices

Diez B. Roggisch deets at nospam.web.de
Thu Feb 22 09:36:42 EST 2007


> Simple plugin system proposal:
> 
> have a package (directory with __init__.py) called plugins where the
> actual plugins are modules in this directory.
> 
> When the main script imports the plugins package, all plugin modules
> would be available as plugins.pluginA, plugins.pluginB , etc.
> 
> A registry of available plugins would be available as a simple
> dir(plugins).
> 
> code in the main script than wished to use a given plugin, would only
> have to look in the registry  before calling any code from a given
> plugin.
> 
> What is wrong/missing with this simple framework?

Nothing wrong. It's just one way of doing it. But it requires you to have
all plugins being part of one module, in one location. Depending on what
you want to do, this won't suffice. For example if your app is installed in
a system path you aren't supposed to write to - how do you install your
individual plugin? easy_install allows you to install to a folder that is
contained in the PYTHONPATH, and then you can discover entrypoints.

But please, do as we suggested: read the past discussions.

Depending on what _you_ actually want to accomplish, you're proposal is
enough. But don't expect it to become the "one plugin system to rule them
all"-solution.

diez



More information about the Python-list mailing list