Search code examples
pythonpypi

use distutils to install link to script into /usr/local/sbin


I have developed a command line utility in python which have 3 modules (for brevity : a.py, b.py, c.py). I want to distribute this for other users to use (if they wish).

I want a.py, b.py & c.py installed into a single directory (presumably under /usr/local/lib/python*.*/) (which I understand is the standard.

The command line is implemented by a.py - and therefore I also want to ensure that a link to a.py is created in /usr/local/sbin/ so that users have access to the command line.

Since @eric-araujo has informed me that I can't use distutils to accomplish that, and I trust his obvious expertise, so how best can i deploy my command line utility and supporting modules and publish them via PyPI.


Solution

  • It sounds like a.py is a script and b.py and c.py are modules.

    If that's the case, use setup.py's "scripts" option to install a.py in a directory where it will be executable. (Under Linux that's likely /usr/bin)

    See https://docs.python.org/2/distutils/setupscript.html#distutils-installing-scripts

    If you want to install the files in a specific place (e.g. '/usr/local/sbin') use the "data_files" option.

    See https://docs.python.org/2/distutils/setupscript.html#installing-additional-files