Differences between revisions 2 and 3
Revision 2 as of 2011-06-28 10:46:02
Size: 5625
Editor: BarryWarsaw
Comment:
Revision 3 as of 2011-06-29 10:49:25
Size: 5709
Editor: BarryWarsaw
Comment:
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:
 * `debian/pycompat`
   * Remove this file (this should have been done long ago).

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.

Before you begin

  • Check if you can do the conversion. All packages that use the same namespace have to be converted at the same time.
    • apt-file search -lix '(packages|pyshared)/foo' might help finding packages with the same namespace (replace foo with your namespace).

Common recommendations

  • debian/control

    • Remove python-central or python-support from Build-Depends and Build-Depends-Indep

    • Bump minimum required python-all (or python, python-dev, python-all-dev) package version to 2.6.6-3~

      • (read /usr/share/doc/python/changelog.Debian.gz to check if you need a newer version)
    • Remove all XB-Python-Version lines

    • If you use CDBS bump the minimum required cdbs version to 0.4.90~

    • 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 actual files in /usr/share/pyshared, plus the symlinks in /usr/lib/python2.x/*-packages.

  • 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 binary package, e.g. python-foo-common to hold the namespace's __init__.py file. dh_python2 will include all __init__.py files, even empty ones.

  • 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.

  • 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 -pfoo

  • Be careful to run a test build! In some cases this reveals new dependencies, because dh_python2 guesses dependencies from egg-info metadata, so if that metadata is wrong then new dependencies may appear. Sometimes the correct fix is to fix the metadata; in other cases the path of least resistance may be to use dh_python2 --no-guessing-deps.

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 BTS

  • The python-support deprecation is not yet tracked.

Packages which Build-Dep on python-central:

Questions?