setuptools tip - script creation

by Jeremy Jones

My last two blog posts on egg-related topics had a title prefix of "easy_install tip". This post is related, but since it's handled with setuptools rather than easy_install, I'm prefixing it accordingly.

Have you ever wondered how various packages you install put scripts into your path, such as into /usr/bin? If they're using setuptools to define their package, then they may be using a script entry point. Here is an example taken and modified from a toy I have sitting around:

entry_points = {
'console_scripts': [
'my_wonderful_script = my_wonderful_module:my_wonderful_function',

If you run
python install
, it will create a script named "my_wonderful_script" in your scripts directory. On Linux, this is typically the same directory that the Python executable itself is in. If you're on Windows, this is a directory that looks something like C:\Python25\scripts. When you run the generated script, it will call `my_wonderful_function` from the module `my_wonderful_module`. This is something that is really easy to setup and can come in very handy. Next time, I'll write about how to control where stuff goes when you easy_install it. I guess we'll be back to the "easy_install" tip prefix.


Noah Gift
2008-01-14 11:51:01
Great tip!
2008-01-16 09:58:21
O.k. but what role does 'console_scripts' play? Any?

A little thin on the exposition. A link to setuptools docs at least, plz. Pretty please?

Phillip J. Eby
2008-01-17 06:38:07
Here are the setuptools docs on this feature.