easy, straightforward way to package a python program for debian?
i'm having trouble navigating the ma开发者_JAVA百科ze of distribution tools for python and debian; cdbs
, debhelper
, python-support
, python-central
, blah blah blah ..
my application is a fairly straightforward one - a single python package (directory containing modules and a __init__.py
), a script for running the program (script.py
) and some icons (.png
) and menu items (.desktop
files).
from these files, how can i construct a simple, clean .deb file from scratch without using the nonsensical tools listed above?
i'm mainly targeting ubuntu, but would like it if the package worked on straight debian
python-stdeb
should work for you. It's on Debian testing/unstable and Ubuntu (Lucid onwards). apt-get install python-stdeb
It is less a shortcut method than a tool that tries to generate as much of the source package as possible. It can actualy build a package that both works properly and is almost standards compliant. If you want your package to meet the quality standards for inclusion in Debian, Ubuntu, etc you will need to fill out files like debian/copyright
, etc.
As much as people claim cdbs is really easy, I'd like to point out that the rules file Nick mentioned could easily have been done with debhelper7. Not to forget, dh7 can be customized far more easily than cdbs can.
#!/usr/bin/make -f
%:
dh $@
Note: You should check whether your package meets the Debian Policy, Debian Python Policy, etc before you submit to Debian. You will actually need to read documents for that - no shortcut.
First, the answer is that there is no straightforward way to make a dpkg, and the documentation is parceled out in a million tiny morsels from as many places. However, the ubuntu Python Packaging Guide is pretty useful.
For simple packages (ones easy to describe to setuptools
), the steps are pretty simple once you have a debian control structure set up:
- Run
setup.py --sdist --prune
and also make sure to setdist-dir
to something reasonable - Invoke
dpkg-buildpackage
with the proper options for your package (probably-b
at least)
You will need a debian/rules
file for buildpackage to function from, but luckily the work is done for you if you use cdbs
, you'll want something very similar to:
#!/usr/bin/make -f
DEB_PYTHON_SYSTEM := pysupport
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk
If you're not using distutils
, you might want to take a look at the DebianPython/Policy page on the wiki (under "CDBS + the hard way"). There is a pycentral
option for DEB_PYTHON_SYSTEM
as well, which you can google if you want to find some more information about.
精彩评论