Reputation: 1851
In the past I saw Python module distributions on PyPI which installed an executable to the path when you installed them with pip
, unfortunately I can't find one like this anymore.
I wonder how this is possible. Would you do this in your setup.py
? Can you get this to work for multiple platforms?
A link to a module doing this would be very helpful as well.
I'm NOT talking about installing python modules to the python path but installing executables to the system path!
Upvotes: 1
Views: 518
Reputation: 1003
Take a look at http://python-packaging.readthedocs.org/en/latest/command-line-scripts.html
The
scripts
Keyword ArgumentThe first approach is to write your script in a separate file, such as you might write a shell script.:
funniest/ funniest/ __init__.py ... setup.py bin/ funniest-joke
... The funniest-joke script just looks like this:
#!/usr/bin/env python import funniest print funniest.joke()
Then we can declare the script in
setup()
like this:setup( ... scripts=['bin/funniest-joke'], ... )
When we install the package,
setuptools
will copy the script to ourPATH
and make it available for general use.
Upvotes: 2