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 myscript.py
to /usr/bin
so that the user can call myscript.py
from any directory.
Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.
(assuming you haven't specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip'ed tar file ( . tar. gz ) on Unix, and ZIP file on Windows.
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)
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'] )
As mentioned here, beside scripts, there is an entry_points
mechanism, which is more cross-platform.
With entry_points
you connect a command line tool name with a function of your choice, whereas scripts
could point to any file (e.g. a shell script).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With