[Distutils] plugin mechanism for packaging itself?

Daniel Holth dholth at gmail.com
Wed Jun 13 05:33:59 CEST 2012


I would like to be able to add a command to packaging for all
packages, not just my own. This is a mechanism that would stay out of
the way of other packages.

1. Distribute a submodule of the namespace package 'packaging_hooks'.
'packaging_hooks.yourpackage' where 'yourpackage' is the pypi name of
the package providing the hook
2. Include in the submodule a dictionary
COMMANDS={'command_name':'class name' or class} and __all__ =
['COMMANDS', ...]

Packaging calls pkgutil.iter_modules(prefix='packaging_hooks.') to
import all the submodules of packaging_hooks, looking for COMMANDS=
and resolving the dotted name of the command class if the value is not
already the command class.

This would only be a plugin mechanism for packaging itself, not a
general-purpose replacement for entry_points.


More information about the Distutils-SIG mailing list