| 1 |
***** |
| 2 |
build |
| 3 |
***** |
| 4 |
|
| 5 |
A simple, correct `Python packaging <https://packaging.python.org/>`_ **build frontend**. |
| 6 |
|
| 7 |
build reads your project's `pyproject.toml configuration file <https://packaging.python.org/en/latest/specifications/pyproject-toml/>`_ and invokes **build backends** to create `distribution packages <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_—the files you upload to `PyPI <https://pypi.org/>`_ or install with pip. It focuses solely on building packages and does not manage dependencies or virtual environments. |
| 8 |
|
| 9 |
Mission Statement |
| 10 |
================= |
| 11 |
|
| 12 |
Many Python tools combine multiple capabilities into one project. For example, pip_ both installs packages and can build them. While convenient, this tight coupling isn't always desirable. Some users need standalone build tools for custom environments (outside PyPI_), or they manage packages themselves (like Linux distributions do). |
| 13 |
|
| 14 |
This project fills that gap by providing a standalone build tool following modern Python packaging standards for how build tools communicate with backends and how ``pyproject.toml`` defines build requirements. |
| 15 |
|
| 16 |
We keep dependencies minimal to make build easy to install and use in restricted environments. |
| 17 |
|
| 18 |
Differences from other tools |
| 19 |
============================= |
| 20 |
|
| 21 |
Thanks to standardization, all compliant build frontends produce the same outputs (`source distributions <https://packaging.python.org/en/latest/specifications/source-distribution-format/>`_ and `wheels <https://packaging.python.org/en/latest/specifications/binary-distribution-format/>`_) from the same project. The differences are mainly in scope, dependencies, and extra features. |
| 22 |
|
| 23 |
``uv build`` |
| 24 |
------------ |
| 25 |
|
| 26 |
`uv build <https://docs.astral.sh/uv/>`_ is essentially equivalent to ``python -m build --installer=uv``. Both follow packaging standards. build offers features like ``--config-json`` for passing complex nested configuration to backends, and the pip installer works on systems that don't have pre-compiled uv wheels. |
| 27 |
|
| 28 |
``setup.py sdist bdist_wheel`` |
| 29 |
------------------------------- |
| 30 |
|
| 31 |
build is the modern equivalent of ``setup.py sdist bdist_wheel``, supporting any backend — not just `setuptools <https://setuptools.pypa.io/>`_. |
| 32 |
|
| 33 |
``hatch build`` |
| 34 |
--------------- |
| 35 |
|
| 36 |
`hatch build <https://hatch.pypa.io/>`_ is the build command from the Hatch project management tool. It provides a convenient wrapper around the build process as part of the larger Hatch ecosystem for managing Python projects, while build is a standalone tool focused solely on building. |
| 37 |
|
| 38 |
``flit build`` |
| 39 |
-------------- |
| 40 |
|
| 41 |
`flit build <https://flit.pypa.io/>`_ is the build command from the Flit project. One important difference: flit-core produces slightly different source distributions when built by flit itself compared to other frontends. Using build (or any standards-compliant frontend) ensures consistent outputs regardless of the backend. |
| 42 |
|
| 43 |
``cibuildwheel`` |
| 44 |
---------------- |
| 45 |
|
| 46 |
`cibuildwheel <https://cibuildwheel.pypa.io/>`_ is a different kind of tool. While build creates a single wheel for the current platform, cibuildwheel orchestrates building wheels across many platforms and Python versions in CI. It actually calls a build frontend (like build or pip) internally for each platform. Use build to create a pure-Python wheel or a single native wheel; use cibuildwheel when you need to produce native wheels for many platforms. |
| 47 |
|
| 48 |
Where to start |
| 49 |
============== |
| 50 |
|
| 51 |
**First time using build?** Start with the :doc:`tutorial/getting-started` to create your first package. |
| 52 |
|
| 53 |
**Need to solve a specific problem?** Check the :doc:`how-to/basic-usage` for common workflows, or browse the how-to guides below for your specific scenario. |
| 54 |
|
| 55 |
**Looking for technical details?** The :doc:`reference/cli` documents all command-line options, and the :doc:`reference/api` covers the Python API. |
| 56 |
|
| 57 |
**Want to understand how it works?** Read :doc:`explanation/how-it-works` to learn about the build process and isolation. |
| 58 |
|
| 59 |
.. toctree:: |
| 60 |
:caption: Tutorial |
| 61 |
:hidden: |
| 62 |
|
| 63 |
tutorial/getting-started |
| 64 |
|
| 65 |
.. toctree:: |
| 66 |
:caption: How-to Guides |
| 67 |
:hidden: |
| 68 |
|
| 69 |
how-to/install |
| 70 |
how-to/basic-usage |
| 71 |
how-to/choosing-tools |
| 72 |
how-to/ci-cd |
| 73 |
how-to/corporate-environments |
| 74 |
how-to/config-settings |
| 75 |
how-to/troubleshooting |
| 76 |
|
| 77 |
.. toctree:: |
| 78 |
:caption: Reference |
| 79 |
:hidden: |
| 80 |
|
| 81 |
reference/cli |
| 82 |
reference/api |
| 83 |
reference/environment-variables |
| 84 |
|
| 85 |
.. toctree:: |
| 86 |
:caption: Explanation |
| 87 |
:hidden: |
| 88 |
|
| 89 |
explanation/how-it-works |
| 90 |
explanation/build-backends |
| 91 |
|
| 92 |
.. toctree:: |
| 93 |
:caption: Development |
| 94 |
:hidden: |
| 95 |
|
| 96 |
development/contributing |
| 97 |
development/release |
| 98 |
Source Code <https://github.com/pypa/build/> |
| 99 |
Issue Tracker <https://github.com/pypa/build/issues> |
| 100 |
|
| 101 |
.. toctree:: |
| 102 |
:caption: Changelog |
| 103 |
:hidden: |
| 104 |
|
| 105 |
changelog |
| 106 |
|
| 107 |
.. _pip: https://github.com/pypa/pip |
| 108 |
.. _PyPI: https://pypi.org/ |
| 109 |
.. _pipx: https://github.com/pipxproject/pipx |