[Distutils] Adding entry points into Distutils ?

Tarek Ziadé ziade.tarek at gmail.com
Tue May 5 17:05:28 CEST 2009

On Tue, May 5, 2009 at 4:29 PM, Doug Hellmann <doug.hellmann at gmail.com> wrote
> I don't think I understand the difference between the step you're calling
> "discover", scanning the registry, and actually loading the plugin.  Does
> "discovering" the plugin involve importing any of its code?

No, like Phillip said somewhere in the thread.

The discovery pseudo-code is:

entry_points = []

for path in paths:
  if path is egg-info:

Then each entry point is just a string that "locates" the plugins
("package.modul.class"  for example)

The real import occurs only explicitely when you do "entry_point.load()"

>> a configuration file that reunites all entry points an application
>> uses. For the Atomisator example:
>>  [atomisator.reader]
>>  rss = somepackage.somemodule:MyPluginClass
> Yes!  We can figure out the exact spelling, but we're talking about the same
> thing now.  If we use dotted notation all the way
> ("somepackage.somemodule.MyPluginClass") then it's simple to just import the
> thing directly.

I think is simpler with the "somepackage.somemodule:MyPluginClass" notation

This is how setuptools does roughly:

   >>> parts = "somepackage.somemodule:MyPluginClass".split(':')
   >>> module = __import__(parts[0])
   >>> plugin = getattr(module, parts[1])

>> And this would fit I think in Distutils needs since we can configure
>> it through three levels of configuration files
>> distutils.cfg, pydistutils.cfg and setup.cfg
> That sounds good.

The only caveat I see though, is that the host app has to know the
exact location
of each plugin in the code of the third party app, whereas entry points provide
this information through the discovery API.

I could leave with both notation I believe:

location = "somepackage.somemodule:MyPluginClass"


location = iter_entry_points('atomisator.reader', 'rss')

Tarek Ziadé | http://ziade.org

More information about the Distutils-SIG mailing list