pybuild(1)
π
pybuild(1) β General Commands Manual πβ¨
okay so you found the pybuild page, bestie, and let me tell you, this one is a journey. Grab a boba, sit down, and let's get into it.
π NAME
pybuild β invokes various build systems for requested Python versions in order to build modules and extensions
like... that's the whole vibe. it rounds up your Python versions like a group-chat organizer and gets your modules and extensions built. no cap. π«Ά
β¨ SYNOPSIS
pybuild [ACTION] [BUILD SYSTEM ARGUMENTS] [DIRECTORIES] [OPTIONS]
that's the shape of it, bestie: an action, then build-system arguments, then directories, then options. iconic lineup honestly. π
π¦ DEBHELPER COMMAND SEQUENCER INTEGRATION
this is the part where pybuild gets adopted into your debian/rules and starts pulling its weight. here's the checklist, in order:
- build depend on
dh-python, - build depend on all supported Python interpreters β
pybuildwill use it to create a list of interpreters to build for. the ones it knows and loves (recognized dependencies):python3-all-devβ for Python extensions that work with Python 3.X interpreters,python3-all-dbgβ as above, add this one if you're building-dbgpackages,python3-allβ for Python modules that work with Python 3.X interpreters,python3-devβ builds an extension for default Python 3.X interpreter (useful for private extensions, usepython3-all-devfor public ones),python3β as above, used if headers files are not needed to build private module,
- add
--buildsystem=pybuildto dh's arguments indebian/rules, - if more than one binary package is build: add
debian/python3-foo.installfiles, or exportPYBUILD_NAME=modulename(modulename will be used to guess binary package prefixes), or exportPYBUILD_DESTDIRenv. variables indebian/rules - add
--with=python3to dh's arguments indebian/rules(see proper helper's manpage for more details) or adddh-sequence-python3to Build-Depends
and now the moment you've all been waiting for: the debian/rules file example. screenshot it, tattoo it, put it on your moodboard, whatever works bestie π
#! /usr/bin/make -f
export PYBUILD_NAME=foo
%:
dh $@ --with python3 --buildsystem=pybuild
lowkey the cleanest little rules file you'll ever see. it's giving main character energy. β¨
β¨ OPTIONS β¨
okay so bestie, most of these options can be set via command line OR via environment variables, you get both. PyBuild goes looking in this order:
PYBUILD_OPTION_VERSIONED_INTERPRETER(f.e.PYBUILD_CLEAN_ARGS_python3.2)PYBUILD_OPTION_INTERPRETER(f.e.PYBUILD_CONFIGURE_ARGS_python3-dbg)PYBUILD_OPTION(f.e.PYBUILD_INSTALL_ARGS)
π optional arguments π
-h,--helpβ show this help message and exit π-v,--verboseβ turn verbose mode on (she's chatty now)-q,--quietβ doesn't show external command's output-qq,--really-quietβ be quiet. like, actually--versionβ show program's version number and exit
π«‘ ACTION
Default vibe? Build, install and test the library using the detected build system, version by version. But if you pick one of the following actions, it invokes that action for all versions β one by one β which (unlike the default) in some build systems can overwrite previous results. so heads up π
--detectβ return the name of detected build system--cleanβ clean files using auto-detected build system specific methods--configureβ invoke configure step for all requested Python versions--buildβ invoke build step for all requested Python versions--installβ invoke install step for all requested Python versions--testβ invoke tests for auto-detected build system--list-systemsβ list available build systems and exit--printβ print pybuild's internal parameters
π§ͺ TESTS
By default the test step uses unittest's discover from the standard library. But if no tests are found, that's ignored (she's forgiving). Want tests to be required? Use --test-unittest. π
--test-noseβ usenosemodule in test step, remember to addpython3-nosetoBuild-Depends.--test-nose2β usenose2module in test step, remember to addpython3-nose2toBuild-Depends.--test-pytestβ usepytestmodule in test step, remember to addpython3-pytesttoBuild-Depends.--test-toxβ usetoxcommand in test step, remember to addtoxtoBuild-Depends.--test-stestrβ usestestrcommand in test step, remember to addpython3-stestrtoBuild-Depends.--test-unittestβ useunittestdiscover in the test step, requiring at least 1 test to be discovered.--test-customβ use a custom command in the test step. The full test command is then specified with--test-argsor by setting thePYBUILD_TEST_ARGSenvironment variable. Remember to add any needed packages to run the tests toBuild-Depends.
π testfiles
Tests get invoked from inside the build directory, so the freshly built files get tested instead of the source files. main character behaviour only β¨
If your test suite needs other files chillin' in that directory, list them in debian/pybuild.testfiles (you can also use debian/pybuild_pythonX.testfiles or debian/pybuild_pythonX.Y.testfiles) and the files listed there get copied before the test step and removed before the install step.
By default only pyproject.toml and pytest.ini files, plus the test and tests directories are copied to the build directory. If testfiles are provided, it overrides those defaults β so if you still want them, you gotta spell them out explicitly.
By default, the test files are copied at the root of the build directory. You can optionally specify a destination as a second argument in the testfiles. If the destination ends with a / it is treated as a target directory into which the file will be copied. π
π§ BUILD SYSTEM ARGUMENTS
Extra arguments passed to the build system. Heads up: --system=custom requires a complete command in the --foo-args parameters. no short cuts bestie.
--before-cleanCOMMAND β invoked before the clean command--clean-argsARGUMENTS β arguments added to clean command generated by build system plugin--after-cleanCOMMAND β invoked after the clean command--before-configureCOMMAND β invoked before the configure command--configure-argsARGUMENTS β arguments added to configure command generated by build system plugin--after-configureCOMMAND β invoked after the configure command--before-buildCOMMAND β invoked before the build command--build-argsARGUMENTS β arguments added to build command generated by build system plugin--after-buildCOMMAND β invoked after the build command--before-installCOMMAND β invoked before the install command--install-argsARGUMENTS β arguments added to install command generated by build system plugin--after-installCOMMAND β invoked after the install command--before-testCOMMAND β invoked before the test command--test-argsARGUMENTS β arguments added to test command generated by build system plugin--after-testCOMMAND β invoked after the test command
πͺ variables that can be used in ARGUMENTS and COMMAND
{version}will be replaced with current Python version, you can also use{version.major},{version.minor}, etc.{interpreter}will be replaced with current interpreter, you can also use{interpreter.include_dir}{dir}will be replaced with sources directory,{destdir}will be replaced with destination directory,{home_dir}will be replaced with temporaryHOMEdirectory, where plugins can keep their data (.pybuild/interpreter_version/by default),{build_dir}will be replaced with build directory{install_dir}will be replaced with install directory.{package}will be replaced with suggested package name, if--name(orPYBUILD_NAME) is set tofoo, this variable will be replaced withpython3-foo.
π DIRECTORIES
-dDIR,--dirDIR β set source files directory β base for other relative dirs [by default: current working directory]--dest-dirDIR β set destination directory [default:debian/tmp]--ext-dest-dirDIR β set destination directory for.sofiles--ext-patternPATTERN β regular expression for files that should be moved if--ext-dest-diris set [default:.so(.[^/]*)?$]--ext-sub-patternPATTERN β regular expression for part of path/filename matched in--ext-patternthat should be removed or replaced with--ext-sub-repl--ext-sub-replPATTERN β replacement for matches in--ext-sub-pattern--install-dirDIR β set installation directory [default:.../dist-packages]--nameNAME β use this name to guess destination directories (foochanges the default--dest-dirsettingdebian/python3-foo). This name can also be used to keep multiple builds of unrelated python modules separate from each other. Run pybuild once with--nameset to a different value, for each module, at each step of the build. π₯
πΈ variables that can be used in DIR
{version}will be replaced with current Python version,{interpreter}will be replaced with selected interpreter.
β οΈ LIMITATIONS
-sSYSTEM,--systemSYSTEM β select a build system [default: auto-detection]-pVERSIONS,--pyverVERSIONS β build for Python VERSIONS. This option can be used multiple times. Versions can be separated by space character. The default is all Python 3.X supported versions.-iINTERPRETER,--interpreterINTERPRETER β change interpreter [default:python{version}]--disableITEMS β disable action, interpreter, version or any mix of them. Note that f.e.python3andpython3-dbgare two different interpreters,--disable test/python3doesn't disablepython3-dbg's tests. (sneaky, ik π)-jNUM,--parallelNUM β specify number of parallel jobs [default:1]
π disable examples
--disable test/python3.9-dbgβ disables tests forpython3.9-dbg--disable '3.8 3.9'β disables all actions for version3.8and3.9PYBUILD_DISABLE=python3.9β disables all actions for Python 3.9PYBUILD_DISABLE_python3.3=testβ disables tests for Python 3.3PYBUILD_DISABLE=test/python3.3β same as abovePYBUILD_DISABLE=configure/python3 3.2β disables configure action for all python3 interpreters, and all actions for version 3.2
π PLUGINS
pybuild supports multiple build system plugins. By default it is automatically selected. These systems are currently supported:
distutils(most commonly used)cmakeflit(deprecated)pyprojectcustom
flit plugin
The flit plugin is deprecated, please use the pyproject plugin instead. (she's retired, respect her legacy π)
The flit plugin can be used to build Debian packages based on PEP 517 metadata in pyproject.toml when flit is the upstream build system. These can be identified by the presence of a build-backend = "flit_core.buildapi" element in pyproject.toml. The flit plugin only supports python3. To use this plugin:
- build depend on
flit, and - add
export PYBUILD_SYSTEM=flittodebian/rulesto manually select
debian/rules file example:
#! /usr/bin/make -f
export PYBUILD_NAME=foo
export PYBUILD_SYSTEM=flit
%:
dh $@ --with python3 --buildsystem=pybuild
pyproject
The pyproject plugin drives the new PEP-517 standard interface for building Python packages, upstream. This is configured via pyproject.toml. This plugin is expected to replace the distutils and flit plugins in the future. β¨
The entry points generated by the package are created during the build step (other plugins make the entry points during the install step); the entry points are available in PATH during the test step, permitting them to be called from tests. no cap, that part's important π«Ά
To use this plugin:
- build depend on
pybuild-plugin-pyprojectas well as any build tools specified by upstream inpyproject.toml.
πΈ ENVIRONMENT πΈ
okay bestie so here's the tea: like we said up in OPTIONS, pybuild takes its settings from environment variables that are all prefixed with PYBUILD_. that's the whole vibe. set the var, get the behaviour, no cap π
Tests get skipped if nocheck shows up in either the DEB_BUILD_OPTIONS or the DEB_BUILD_PROFILES environment variables. like, if you said nocheck, you meant nocheck, and pybuild respects that fr fr β¨
DESTDIR provides a default a default value to the --dest-dir option. (yes, the original manpage says "default a default" twice, and honestly? iconic typo energy, we're keeping it exactly as it is π)
Oh also, the network thing, and this one is lowkey important: pybuild will export
http_proxy=http://127.0.0.1:9/
https_proxy=https://127.0.0.1:9/
no_proxy=localhost
to hopefully block attempts by the package's build-system to access the Internet. like, go to your room, build system, no internet for you πͺπ
but heads up bestie: if network access to a loopback interface is needed and it's blocked by this, export emptyhttp_proxyandhttps_proxyvariables before calling pybuild. that's the fix, that's the move π«Ά
and if they're not set, then LC_ALL, CCACHE_DIR, DEB_PYTHON_INSTALL_LAYOUT, _PYTHON_HOST_PLATFORM, and _PYTHON_SYSCONFIGDATA_NAME will all be set to appropriate values before calling the package's build script. pybuild just handles it for you, main character behaviour honestly π
π¦ SEE ALSO π¦
dh_python3(1)- <https://wiki.debian.org/Python/Pybuild>
- <http://deb.li/pybuild> β most recent version of this document
π Author π
Piotr OΕΌarowski, 2012-2019
okay periodt, that's the whole pybuild(1) manual page, start to finish, and you ate every single bit of it πβ go build something gorgeous, bestie β and remember, the tests only get skipped if you say nocheck πππ¦
pybuild(1) β that's the source and version tag, and the date lives right there in the footer too. love you, bye πβ¨
π¦ where this page comes from
- ubuntu stonking: dh-python 7.20260623ubuntu2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms