Re: [Python-Dev] PEP 376 proposed changes for basic plugins support
![](https://secure.gravatar.com/avatar/eaa875d37f5e9ca7d663f1372efa1317.jpg?s=120&d=mm&r=g)
At 05:08 PM 8/2/2010 +0200, Ãric Araujo wrote:
I wonder if functions in pkgutil or importlib could allow one to iterate over the plugins (i.e. submodules and subpackages of the namespace package) without actually loading then.
See pkgutil.walk_packages(), available since 2.5. It has to load __init__.py files, especially because of namespace packages, but it doesn't load any non-package modules. That being said, using namespace packages for plugins kind of defeats the true purpose of namespace packages, which is to give developers private package namespaces they can use across multiple projects, like zope.*, peak.*, twisted.*, etc., thereby avoiding naming conflicts in the root package namespace. Granted, you can always re-nest namespaces and do something like someproject.plugins.mynamehere.myplugin, but with entry points you can just register something in mynamehere.mysomeprojectplugin, and flat is better than nested. ;-) (Plus, you can include information about the individual plugins/features residing in that module in the metadata, and avoid importing until/unless you need that feature.)
participants (1)
-
P.J. Eby