Transition to dh_python2
Rationale: The two traditionally popular Python helpers, python-support and python-central have both been deprecated in favor of dh_python2. This page explains how to convert your existing pycentral or pysupport packages to dh_python2.
Common recommendations
debian/control
Replace python-central or python-support with dh-python in Build-Depends. dh-python does not explicitly depend on python, so you need an explicit build dependency on python if that is missing.
Remove all XB-Python-Version lines
XS-Python-Version is still supported, but X-Python-Version is preferred. It supports the same syntax, except current and all keywords are gone. If you don't know what the package's minimum required Python version is, don't add this field until a bug report informs you that foo doesn't work with an older Python version.
debian/rules
Remove the DEB_PYTHON_SYSTEM line, e.g.
For python-support, run sed -i -e '/DEB_PYTHON_SYSTEM[[:space:]]*[?:]*=[[:space:]]*pysupport/d' debian/rules
For python-central, run sed -i -e '/DEB_PYTHON_SYSTEM[[:space:]]*[?:]*=[[:space:]]*pycentral/d' debian/rules
If you are using CDBS and any of the modules are in a (Debian binary) package whose name isn't "python-*", set DEB_PYTHON2_MODULE_PACKAGES to the space-separated list of (Debian binary) package names you're building.
If you use dh sequencer, add python2 to dh's --with
If you use pure debhelper, replace the old helper with dh_python2, e.g.
For python-support, run sed -i -e 's/dh_pysupport/dh_python2/' debian/rules
For python-central, run sed -i -e 's/dh_pycentral/dh_python2/' debian/rules
Check if debian/*.install and other files need additions. dh_python2 ships the files in /usr/lib/python2.7/dist-packages (/usr/share/pyshared was implementation detail, not used anymore since 2.6 is dead and pysupport deprecated).
debian/pyversions
- Remove this file.
Use X-Python-Version in debian/control instead (see above, and also policy for syntax, example: ">= 2.5")
debian/pycompat
- Remove this file (this should have been done long ago).
Special cases
If you depend on python-support's "namespace feature", remember to provide the namespace's __init__.py file in only one binary package. If you cannot use an existing binary package, create a new one, e.g. python-foo-common to hold the namespace's __init__.py file. dh_python2 will include all __init__.py files, even empty ones (unless the namespace is listed in namespace_packages.txt or added via --namespace).
Some packages include /usr/share/pycentral-data/pycentral.mk for its sitedir definition. py_libdir from /usr/share/python/python.mk serves the same purpose, but note that it includes the /usr/lib/pythonX.Y/ prefix.
DH_PYCENTRAL=include-links can be dropped; dh_python2 does this by default.
DH_PYCENTRAL=nomove can be dropped; dh_python2 does this by default, except that it replaces files with symlinks to pyshared if they can be shared between Python versions.
If you have both public and private modules, and your rules file runs dh_python2 explicitly, you'll need to run it twice, since the compilation of public and private modules are done separately. See the manpage for details, e.g.
dh_python2
dh_python2 /path/to/private/dir
python-support's debian/package.private files are not supported, add dh_python2 private_dir (next to dh_python2 call) to debian/rules instead
If you have extension modules, and a setup.py that builds them, dh will do the right thing unless your package also has a top-level Makefile. The Makefile will be used instead of setup.py, so you'll need to override this by adding a --buildsystem python_distutils to your dh line. Also, be sure to Build-Depend on python-all or python-all-dev to build it for all supported Pythons.
Helpful hints
Build the package both before and after your conversion to dh_python2, then use debdiff on the two .deb files to see the differences in the contents of the packages.
- TBD: expected changes...
Backports
- dh_python2 was released with squeeze, so your backported package transitions should work in squeeze too.
Bug and Status Tracking
Bugs:
The python-central deprecation is tracked in the BTS
The python-support deprecation is tracked in the BTS
The dh_python deprecation is tracked in the BTS
Packages which build-depend on python-central and python-support
Questions?
Read man dh_python2
Ask on the official #debian-python IRC channel
Ask on the official debian-python@lists.debian.org mailing list
Footnotes
(1) This is because of the way namespace packages __init__.py files are handled. Until PEP 382 or 402 lands (which won't help Python 2 at all), you have package collisions for namespace __init__.py files. Each Python packaging regime has its own way of handling this and you don't want conflicting regimes or you're just asking for trouble. Thus all packages which share a namespace must use the same Python helper.