I can\'t figure out how to make setup.py
add a scrip to the the user\'s /bin
or /usr/bin
or whatever.
E.g., I\'d like to add a
Consider using console_scripts
:
from setuptools import setup
setup(name='some-name',
...
entry_points = {
'console_scripts': [
'command-name = package.module:main_func_name',
],
},
)
Where main_func_name
is a main function in your main module.
command-name is a name under which it will be saved in /usr/local/bin/ (usually)
If you're willing to build and install the entire python package, this is how I would go about it:
setup(name='myproject',author='',author_email='',scripts=['bin/myscript.py'])
mkdir bin
bin
directory (and make sure it's executable!)cd
into the directory that contains setup.py again, and install the entire python package by typing python setup.py install
The Python documentation explains it under the installing scripts section.
Scripts are files containing Python source code, intended to be started from the command line.
setup(...,
scripts=['scripts/xmlproc_parse', 'scripts/xmlproc_val']
)
There are two ways in order to get a working command line tool from setuptools and PyPI infrastructure: