/
Depends on
- debhelper (debhelper)
- dpkg (dpkg-dev, libdpkg-perl)
- flit (flit)
- make-dfsg (make)
- nose2 (python3-nose2)
- python-build (python3-build)
- python-docutils (python3-docutils)
- python3-defaults (libpython3-stdlib, python3, python3-all, python3-all-dbg, python3-all-dev, python3-minimal)
- setuptools (python3-setuptools)
- wheel (python3-wheel)
- debhelper-compat, python3-installer
README (full)
dh-python
dh-python provides various tools that help packaging Python related files in Debian.
-
pybuildis a tool that implementsdhsequencer'sdh_auto_foocommands (but it can be used outside
dhas well). It builds and installs files. -
dh_python3is a tool that takes whatpybuildproduces andgenerates runtime dependencies and maintainer scripts. It fixes some common mistakes, like installing files into
site-packagesinstead ofdist-packages,/usr/local/bin/shebangs, removes.pyfiles from-dbgpackages, etc.)To translate
requires.txt(a file installed indist-packages/foo.egg-info/) into Debian dependencies, a list of packages that provide given egg distribution is used. If the dependency is not found there,dpkg -Sis used (i.e. a given dependency has to be installed; you need it inBuild-Dependsin order to run tests anyway). See dependencies section indh_python3's manpage for more details.-
dh_python3works on./debian/python3-foo/files and other binarypackages that have
${python3:Depends}in theDependsfield. Seedh_python3manpage for more details.
-
How it works
A simplified work flow looks like this:
# dh_auto_clean stage
for interpreter in REQUESTED_INTERPRETERS:
for version in interpreter.REQUESTED_VERSIONS:
PYBUILD_BEFORE_CLEAN
pybuild --clean
PYBUILD_AFTER_CLEAN
plenty_of_other_dh_foo_tools_invoked_here
# dh_auto_configure stage
for interpreter in REQUESTED_INTERPRETERS:
for version in interpreter.REQUESTED_VERSIONS:
PYBUILD_BEFORE_CONFIGURE
pybuild --configure
PYBUILD_AFTER_CONFIGURE
plenty_of_other_dh_foo_tools_invoked_here
# dh_auto_build stage
for interpreter in REQUESTED_INTERPRETERS:
for version in interpreter.REQUESTED_VERSIONS:
PYBUILD_BEFORE_BUILD
pybuild --build
PYBUILD_AFTER_BUILD
plenty_of_other_dh_foo_tools_invoked_here
# dh_auto_test stage
for interpreter in REQUESTED_INTERPRETERS:
for version in interpreter.REQUESTED_VERSIONS:
PYBUILD_BEFORE_TEST
pybuild --test
PYBUILD_AFTER_TEST
plenty_of_other_dh_foo_tools_invoked_here
# dh_auto_install stage
for interpreter in REQUESTED_INTERPRETERS:
for version in interpreter.REQUESTED_VERSIONS:
PYBUILD_BEFORE_INSTALL
pybuild --install
PYBUILD_AFTER_INSTALL
plenty_of_other_dh_foo_tools_invoked_here
dh_python3
plenty_of_other_dh_foo_tools_invoked_here
pybuild --$step
This command is auto-detected, it currently supports distutils, autotools, cmake and a custom build system where you can define your own set of commands. Why do we need it? dh_auto_foo doesn't know each command has to be invoked for each interpreter and version.
REQUESTED_INTERPRETERS
is parsed from Build-Depends if --buildsystem=pybuild is set. If it's not, you have to pass --interpreter to pybuild (more in its manpage)
-
python3-all{,-dev}- all CPython interpreters (for packages thatprovide public modules / extensions)
-
python3-all-dbg- all CPython debug interpreters (if-dbgpackageis provided)
-
python3- default CPython or closest to default interpreter only (usethis if you build a Python application)
-
python3-dbg- default CPython debug (or closest to the default one)only
REQUESTED_VERSIONS
is parsed from X-Python3-Version and Build-Depends.
BEFORE and AFTER commands
can be different for each interpreter and/or version, examples:
PYBUILD_AFTER_BUILD_python3.5=rm {destdir}/{build_dir}/foo/bar2X.pyPYBUILD_BEFORE_INSTALL_python3=touch {destdir}/{install_dir}/foo/bar/__init__.py
These commands should be used only if overriding dh_auto_foo is not enough (example below)
override_dh_auto_install: before_auto_install_commands dh_auto_install after_auto_install_commands
See the pybuild manpage for more details (search for BUILD SYSTEM ARGUMENTS)
overrides
How to override pybuild autodetected options:
-
Each
pybuildcall can be disabled (for given interpreter, version orstage). See the
pybuildmanpage for more details (search for--disabledescription). -
You can pass options in
override_dh_auto_foovia command line options:dh_auto_test -- --system=custom --test-args='{interpreter} setup.py test'
or env. variables:
PYBUILD_SYSTEM=custom PYBUILD_TEST_ARGS='{interpreter} setup.py test' dh_auto_test
-
You can export env. variables globally at the beginning of debian/rules
export PYBUILD_TEST_ARGS={dir}/tests/
How to override dh_python3 options:
* via command line, f.e.
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
| dir | autoscripts/ |
| dir | debian/ |
| dir | dh/ |
| dir | dhpython/ |
| dir | pydist/ |
| dir | tests/ |
| file | .gitlab-ci.yml |
| file | Makefile |
| file | README.rst |
| file | dh_python3 |
| file | dh_python3.rst |
| file | pybuild |
| file | pybuild-autopkgtest |
| file | pybuild-autopkgtest.rst |
| file | pybuild.rst |
| file | pyproject.toml |