Jeff Watkins wrote: > Can anyone point me to a quick example of how this actually works? > I've looked at the setup tools web site, but I didn't understand it.
Someone's already mentioned TurboGears' setup script. Here are a few other links with examples: http://groovie.org/articles/2005/09/29/setuptools-and-python-paste http://pythonpaste.org/script/developer.html Neither of these really explain from the point of view of the person who's trying to create a system of plugins, though. I'll try and give a brief explanation. Entry points let you do simple plugins. If you want to have some kind of plugins (like Turbogears' widgets), you simply come up with a unique name for an "entry point group" that will identify what kind of plugins they are. You need this name because entry points can be used for lots of things and this lets you distinguish your application/framework's entry points from those belonging to others. Let's say you decide to call your group 'turbogears.widgets' (the name has to be a dotted Python identifier). Now, in your application, you would use the EntryPoint API: http://peak.telecommunity.com/DevCenter/PkgResources#entry-points in order to look up the entry points that people have provided in their eggs, that are in that group. In the simplest example, you could do something like this: for ep in pkg_resources.iter_entry_points('turbogears.widgets'): print "Found widget", ep.name, "from", ep.dist This will print a list of things like "Found widget foobar in SuperTGWidgets-1.2". Each entry point object has a load() method that will return whatever the entry point was registered as. So for example, you could have people register their widget classes in their eggs' setup.py scripts, and then when the eggs are installed, their entry points will show up in the list automatically. That's really all there is to it - it's a way for a plugin to "advertise" a Python object it has, under an agreed-upon group name, for applications or frameworks to find, import, and "plug in". The rest is mostly details. You need to give each individual entry point a name, not just the group. The meaning of this name depends on what you're doing with it. For setuptools commands and tg-admin commands, the name is what you type on the command line to run that command. For other applications, the name might be ignored, or it might be the name of a keystroke combination that will activate a command in an editor. Or the name might be just used to identify the entry point in other configuration files, to enable optional features or plugins. So, there's not much to entry points, really. It's all in how you decide to use them. By themselves, they're sort of like files and directories - if you had a convention for how to organize plugins, they'd be useful. If you don't know what you want to do with plugins, it's just an empty box with nothing to put in it.

