|
| 1 | +.. SPDX-FileCopyrightText: 2024 The meson-python developers |
| 2 | +.. |
| 3 | +.. SPDX-License-Identifier: MIT |
| 4 | +
|
| 5 | +.. _sdist: |
| 6 | + |
| 7 | +****************************** |
| 8 | +Creating a source distribution |
| 9 | +****************************** |
| 10 | + |
| 11 | +A source distribution for the project can be created executing |
| 12 | + |
| 13 | +.. code-block:: console |
| 14 | +
|
| 15 | + $ python -m build --sdist . |
| 16 | +
|
| 17 | +in the project root folder. This will create a ``.tar.gz`` archive in the |
| 18 | +``dist`` folder in the project root folder. This archive contains the full |
| 19 | +contents of the latest commit in revision control with all revision control |
| 20 | +metadata removed. Uncommitted modifications and files unknown to the revision |
| 21 | +control system are not included. |
| 22 | + |
| 23 | +The source distribution archive is created by adding the required metadata |
| 24 | +files to the archive obtained by executing the ``meson dist --no-tests |
| 25 | +--allow-dirty`` command. To generate a source distribution, ``meson-python`` |
| 26 | +must successfully configure the Meson project by running the ``meson setup`` |
| 27 | +command. Additional arguments can be passed to ``meson dist`` to alter its |
| 28 | +behavior. Refer to the relevant `Meson documentation`__ and to the |
| 29 | +:ref:`how-to-guides-meson-args` guide for details. |
| 30 | + |
| 31 | +The ``meson dist`` command uses the archival tool of the underlying revision |
| 32 | +control system for creating the archive. This implies that a source |
| 33 | +distribution can only be created for a project versioned in a revision control |
| 34 | +system. Meson supports the Git and Mercurial revision control systems. |
| 35 | + |
| 36 | +Files can be excluded from the source distribution via the relevant mechanism |
| 37 | +provided by the revision control system. When using Git as a revision control |
| 38 | +system, it is possible to exclude files from the source distribution setting |
| 39 | +the ``export-ignore`` attribute. For example, adding a ``.gitattributes`` |
| 40 | +files containing |
| 41 | + |
| 42 | +.. code-block:: none |
| 43 | +
|
| 44 | + dev/** export-ignore |
| 45 | +
|
| 46 | +would result in the ``dev`` folder to be excluded from the source |
| 47 | +distribution. Refer to the ``git archive`` documentation__ for |
| 48 | +details. Another mechanism to alter the content of the source distribution is |
| 49 | +offered by dist scripts. Refer to the relevant `Meson documentation`__ for |
| 50 | +details. |
| 51 | + |
| 52 | +__ https://mesonbuild.com/Creating-releases.html |
| 53 | +__ https://git-scm.com/docs/git-archive#ATTRIBUTES |
| 54 | +__ https://mesonbuild.com/Reference-manual_builtin_meson.html#mesonadd_dist_script |
0 commit comments