-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Just a quick question as I'm starting to play with this feature. Why do entry point values use a colon to separate the module from the callable? 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. Cheers, - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iQCVAwUBRqZtZnEjvBPtnXfVAQIOHwP6AgX58dLBIzqvI7wo+z9MOIXm/rUIDikX j6Zc5S/97Fc9n3qjRlKf/fTT229oQVSIsPJgxvfXxWKYS5Qlk+YqhoACI9BuTbrm KshRSiPzFPy2eqjk287sHmrpq1MJWwrccjF4lSROn6VDcojlW/t2p6FY/+Gvj3au CPhRo/Amr+M= =8qj5 -----END PGP SIGNATURE-----
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. :)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Jul 24, 2007, at 6:09 PM, Phillip J. Eby wrote:
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.
Fair enough. That wasn't entirely evident from the documentation, but maybe I wasn't looking in the right place or didn't grok what I was reading. ;) By now I've gotten my first plugin to work, and it's really quite awesome. Between setuptools and zope.interface, I'm just very psyched that I now have a principled and standard way of providing extensibility for my application. One thing I think will have to be done at some point is to consolidate all the documentation on the telecommunity site. I find myself with three open browser tabs (setuptools, PkgResources, and EasyInstall). There's /a lot/ of information there. I vote the PSF pays for a tech writer to put it all together into a single cohesive manual. Thanks for the explanation regarding the choice of ':'. I suspected you had a good reason for it. :) - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iQCVAwUBRqaF7nEjvBPtnXfVAQL85wQArnlzXZCd20QhGfk53ac9F0JB1tj0FcYP JMofaetnelHti/Fh/uMEK+S4Uxf1RnEwQwixXvk9YXvGwlVnrZINPELlx57FB4tB xpNlcwtkBRa0HCTP1LtyniQ0h+4PbHIHeNmvFskQ7+5YJCdGZYX5vffOScFlomSF tMtbU1XrZqQ= =KrB4 -----END PGP SIGNATURE-----
participants (2)
-
Barry Warsaw
-
Phillip J. Eby