Issue
I try to create a debian package of a python application as follows:
- Write a setup.py
- Generate a debian folder by stddeb
- Run dpkg-buildpackage -b -rfakeroot -uc to build the debian package
The setup.py is like
#!/usr/bin/env python
from distutils.core import setup
setup(name='foo',
version='1.0.0',
description='Foo example',
author='Kuan-Kai Chiu',
author_email='[email protected]',
scripts=['src/foo.py']
)
How do I install the foo.py to /usr/local/bin instead of being installed to /usr/bin? I know there's an option --install-scripts=/usr/local/bin while running python setup.py install, but I have to debianize my python application and it seems no way to specify the install-scripts prefix.
Thanks in advance!
Solution
If you just want to install a file in /usr/local/bin/
, then drop the setup.py
as it's not really needed. If you are using dh
in your package (you can see if you are by checking it's being invoked in your debian/rules
file. If you aren't using it, you should :-), then you'll only have to feed dh_install
(see its manpage) with an install
file. The syntax of this file is really simple, you have to specify what do you want to install, and where. You can do this by issuing the following command in the root directory of your package:
$ echo "src/foo.py usr/local/bin" > debian/install
Now, as you want to install a script under /usr/local/
, and this is against the Debian policy, one of the dh_*
tools will fail. This tool is dh_usrlocal
. The fix is quite simple. We just have to tell debian/rules
that we don't want to run it, and we can do this by overriding its behavior. This is how your final debian/rules
should look:
#!/usr/bin/make -f
# -*- makefile -*-
%:
dh $@
override_dh_usrlocal:
That's it. Run dpkg-buildpackage
and you should have your fresh new packages in ../
.
Answered By - rul