[Distutils] entry points

Phillip J. Eby pje at telecommunity.com
Wed Jul 25 00:09:30 CEST 2007


At 05:21 PM 7/24/2007 -0400, Barry Warsaw wrote:
>Why do entry point values use a colon to separate the module from the
>callable?

First off, an entry point need not be callable in the general 
case.  Classes and arbitrary data structures can be entry points, 
too.  Heck, Chandler parcel entry points are just a module name.


>   Couldn't you just as easily use a "normal" Python dotted
>path, the last component of which would of course be the callable?
>
>E.g. instead of
>
>setup(
>      # ...
>      entry_points = {'blogtool.parsers': '.rst = some_module:SomeClass'}
>)
>
>use
>
>setup(
>      # ...
>      entry_points = {'blogtool.parsers': '.rst = some_module.SomeClass'}
>)
>
>That would seem a bit more Pythonic.

Perhaps, but it's also a PITA to implement correctly in the presence 
of things like classmethods and other objects that could be 
legitimate targets for entry points.  It requires a fair amount of 
error trapping, and the precise errors aren't always the same from 
one version of Python to the next.  (Note, btw, that a module itself 
can be a valid entry point.)

So, even though I implemented that algorithm correctly in 
peak.util.imports many years ago (available now as a standalone 
package "Importing" from the Cheeseshop), I decided to never do it 
again anywhere else.  And since pkg_resources needs to be able to run 
without any other packages installed, I did the practical thing 
instead of the pure thing, by requiring people to be explicit instead 
of implicit.  :)



More information about the Distutils-SIG mailing list