dh-python
TLDR
Build Python 3 package with debhelper
SYNOPSIS
dh_python3 [options]
dh_python2 [options] (deprecated)
DESCRIPTION
dh-python provides debhelper extensions for packaging Python modules and applications in Debian. The main commands are dh_python3 for Python 3 packages and the deprecated dh_python2 for Python 2.
These tools handle Python-specific packaging tasks: byte-compiling modules, generating dependencies from Python metadata, fixing shebangs to use system Python, and creating proper package relationships.
In debian/rules, dh_python3 is typically invoked automatically through the dh sequencer with --with python3. It reads configuration from debian/control and Python metadata files.
PARAMETERS
-p, --package package
Act on specified package.-n, --no-package package
Exclude package.--shebang path
Use specific Python interpreter in shebangs.--depends section
Generate dependencies from specified section.--recommends section
Generate recommends from specified section.--suggests section
Generate suggests from specified section.-v, --verbose
Verbose output.-Oopt
Pass option to debhelper.
DEBIAN/RULES EXAMPLE
%:
dh $@ --with python3 --buildsystem=pybuild
CAVEATS
Python 2 support (dh_python2) is deprecated and removed from modern Debian. Multiple Python versions require careful handling. Virtual environments are not directly supported; packages install to system directories. Byte-compilation errors may indicate syntax issues.
HISTORY
dh-python was developed for Debian to replace the older python-support and python-central systems. Created by Piotr Ożarowski around 2012, it provided a cleaner approach to Python packaging as Python 3 became standard. The tool became the standard method for Debian Python packages and is used by Ubuntu and derivatives.
SEE ALSO
pybuild(1), dh(1), debhelper(7), py3compile(1)


