I've almost finished developing a python package and have also written a basic setup.py using distutils:
#!/usr/bin/env python
#@author: Prahlad Yeri
#@description: Small daemon to create a wifi hotspot on linux
#@license: MIT
import cli
#INSTALL IT
from distutils.core import setup
setup(name='hotspotd',
version='0.1',
description='Small daemon to create a wifi hotspot on linux',
license='MIT',
author='Prahlad Yeri',
author_email='prahladyeri@yahoo.com',
url='https://github.com/prahladyeri/hotspotd',
package_dir={'hotspotd': ''},
packages=['hotspotd'],
data_files=[('config',['run.dat'])],
)
#CONFIGURE IT
Now this script works perfectly as I want. It installs the required files to the prefixed folder. For example, the below command:
sudo python setup.py install --prefix /opt
will install my entire package in:
/opt/lib/python2.7/site-packages/hotspotd
However, I want the major executable, hotspotd.py to be symlinked to an appropriate file in /usr/bin such as:
/usr/bin/hotspotd
So that the user can start my program by simply calling hotspotd start
instead of indirectly invoking through python.
How can I achieve this by modifying the setup.py? If I just write the copying code at the end after the setup() call, it would be called each time. I just want it done when the program is being installed.