File: build.md

package info (click to toggle)
pdm 2.23.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,516 kB
  • sloc: python: 24,994; javascript: 34; makefile: 12
file content (72 lines) | stat: -rw-r--r-- 2,113 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Build Configuration

`pdm` uses the [PEP 517](https://www.python.org/dev/peps/pep-0517/) to build the package. It acts as a build frontend that calls the build backend to build the package.

A build backend is what drives the build system to build source distributions and wheels from arbitrary source trees.

If you run [`pdm init`](../reference/cli.md#init), PDM will let you choose the build backend to use. Unlike other package managers, PDM does not force you to use a specific build backend. You can choose the one you like. Here is a list of build backends and corresponding configurations initially supported by PDM:

=== "pdm-backend"

    `pyproject.toml` configuration:

    ```toml
    [build-system]
    requires = ["pdm-backend"]
    build-backend = "pdm.backend"
    ```

    [:book: Read the docs](https://backend.pdm-project.org/)

=== "setuptools"

    `pyproject.toml` configuration:

    ```toml
    [build-system]
    requires = ["setuptools", "wheel"]
    build-backend = "setuptools.build_meta"
    ```

    [:book: Read the docs](https://setuptools.pypa.io/)

=== "flit"

    `pyproject.toml` configuration:

    ```toml
    [build-system]
    requires = ["flit_core >=3.2,<4"]
    build-backend = "flit_core.buildapi"
    ```

    [:book: Read the docs](https://flit.pypa.io/)

=== "hatchling"

    `pyproject.toml` configuration:

    ```toml
    [build-system]
    requires = ["hatchling"]
    build-backend = "hatchling.build"
    ```

    [:book: Read the docs](https://hatch.pypa.io/)

=== "maturin"

    `pyproject.toml` configuration:

    ```toml
    [build-system]
    requires = ["maturin>=1.4,<2.0"]
    build-backend = "maturin"
    ```

    [:book: Read the docs](https://www.maturin.rs/)

Apart from the above mentioned backends, you can also use any other backend that supports PEP 621, however, [poetry-core](https://python-poetry.org/) is not supported because it does not support reading PEP 621 metadata.

!!! info
    If you are using a custom build backend that is not in the above list, PDM will handle the relative paths as PDM-style(`${PROJECT_ROOT}` variable).