Skip to content

Commit 09cfd8e

Browse files
committed
DOC: document how to create source distributions
1 parent 192be5c commit 09cfd8e

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

docs/explanations/design-old.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ Python tool (pip_, `pypa/build`_, etc.) to build and install the project.
3131
``meson-python`` will build a Python sdist (source distribution) or
3232
wheel (binary distribution) from Meson_ project.
3333

34-
Source distribution (sdist)
35-
---------------------------
36-
37-
The source distribution is based on ``meson dist``, so make sure all your files
38-
are included there. In git projects, Meson_ will not include files that are not
39-
checked into git, keep that in mind when developing. By default, all files
40-
under version control will be included in the sdist. In order to exclude files,
41-
use ``export-ignore`` or ``export-subst`` attributes in ``.gitattributes`` (see
42-
the ``git-archive`` documentation for details; ``meson dist`` uses
43-
``git-archive`` under the hood).
44-
45-
Local (uncommitted) changes to files that are under version control will be
46-
included. This is often needed when applying patches, e.g. for build issues
47-
found during packaging, to work around test failures, to amend the license for
48-
vendored components in wheels, etc.
4934

5035
Binary distribution (wheels)
5136
----------------------------

docs/how-to-guides/sdist.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ the use of ``meson-python`` and Meson for Python packaging.
7777
:hidden:
7878

7979
tutorials/introduction
80+
how-to-guides/sdist
8081
how-to-guides/editable-installs
8182
how-to-guides/config-settings
8283
how-to-guides/meson-args

0 commit comments

Comments
 (0)