Debian Codegraph @

README.md

raw
1 # build
2
3 [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pypa/build/main.svg)](https://results.pre-commit.ci/latest/github/pypa/build/main)
4 [![CI test](https://github.com/pypa/build/actions/workflows/test.yml/badge.svg)](https://github.com/pypa/build/actions/workflows/test.yml)
5 [![codecov](https://codecov.io/gh/pypa/build/branch/main/graph/badge.svg)](https://codecov.io/gh/pypa/build)
6
7 [![Documentation Status](https://readthedocs.org/projects/pypa-build/badge/?version=latest)](https://build.pypa.io/en/latest/?badge=latest)
8 [![PyPI version](https://badge.fury.io/py/build.svg)](https://pypi.org/project/build/)
9 [![Discord](https://img.shields.io/discord/803025117553754132?label=Discord%20chat%20%23build)](https://discord.gg/pypa)
10
11 A simple, correct Python build frontend.
12
13 See the [documentation](https://build.pypa.io) for more information.
14
15 ### Installation
16
17 `build` can be installed via `pip` or an equivalent via:
18
19 ```console
20 $ pip install build
21 ```
22
23 ### Usage
24
25 ```console
26 $ python -m build
27 ```
28
29 This will build the package in an isolated environment, generating a
30 source-distribution and wheel in the directory `dist/`. See the
31 [documentation](https://build.pypa.io) for full information. Build is also
32 available via the command line as `pyproject-build` once installed.
33
34 ### Common arguments
35
36 - `--sdist` (`-s`): Produce just an SDist
37 - `--wheel` (`-w`): Produce just a wheel
38 - `--metadata`: Produce just the metadata as JSON. Cannot be used with `--sdist`/`--wheel`.
39 - `-C<option>=<value>`: A Config-setting, the PEP 517 way of passing options to a backend. Can be passed multiple times. Matching options will make a list. Note that setuptools has very limited support.
40 - `--config-json=<value>`: An alternative way to pass in complex config settings as JSON strings. Can't be used with `-C`.
41 - `--installer`: Pick an installer for the isolated build (`pip` or `uv`).
42 - `--no-isolation` (`-n`): Disable build isolation.
43 - `--skip-dependency-check` (`-x`): Disable dependency checking when not isolated; this should be done if some requirements or version ranges are not required for non-isolated builds.
44 - `--outdir` (`-o`): The output directory (defaults to `dist`)
45
46 Some common combinations of arguments:
47
48 - `--sdist --wheel` (`-sw`): Produce an SDist and a wheel, both from the source distribution. The default (if no flag is passed) is to build an SDist and then build a wheel _from_ the SDist.
49 - `-nx`: Disable build isolation and dependency checking. Identical to pip and uv's `--no-build-isolation` flag.
50 - `--metadata | jq -r .version`: get the version in a bash-like environment.
51
52 ### Integration with other tools
53
54 #### pipx
55
56 If you use [pipx][], such as in GitHub Actions, the following command will download
57 and run build in one step:
58
59 ```console
60 $ pipx run build
61 ```
62
63 #### uv
64
65 If you want to use [uv][] to speed up the virtual environment creation, you can
66 use `--installer=uv`. You can get a Python wheel for `uv` with the `[uv]`
67 extra. For example, using pipx like above:
68
69 ```console
70 $ pipx run 'build[uv]' --installer uv
71 ```
72
73 If you already have uv, you don't need the extra. For example:
74
75 ```console
76 $ uvx --from build pyproject-build --installer uv
77 ```
78
79 #### cibuildwheel
80
81 If you are using [cibuildwheel][], build is integrated and the default builder in 3.0+. If you want to use `uv` as the installer, you can use:
82
83 ```toml
84 [tool.cibuildwheel]
85 build-frontend = "build[uv]"
86 ```
87
88 (Be sure to pre-install uv before running cibuildwheel for this one!)
89
90 #### Conda-forge
91
92 On conda-forge, this package is called [python-build][].
93
94 ### Code of Conduct
95
96 Everyone interacting with build's codebase, issue trackers, chat rooms, and mailing lists is expected to follow
97 the [PSF Code of Conduct].
98
99 [psf code of conduct]: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
100 [pipx]: https://pipx.pypa.io
101 [uv]: https://docs.astral.sh/uv/
102 [cibuildwheel]: https://cibuildwheel.pypa.io
103 [python-build]: https://github.com/conda-forge/python-build-feedstock