Skip to content

Commit 0d2df77

Browse files
committed
DOC: add docs on using the build-dir config setting
Closes gh-540 Also touches on gh-246, which is a common enough hiccup that it's useful to explicitly show dealing with `meson-log.txt` in CI.
1 parent adfe8cd commit 0d2df77

File tree

2 files changed

+68
-5
lines changed

2 files changed

+68
-5
lines changed

docs/how-to-guides/config-settings.rst

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the ``-C`` short command line option:
1919

2020
.. tab-set::
2121

22-
.. tab-item:: pypa/buid
22+
.. tab-item:: pypa/build
2323
:sync: key_pypa_build
2424

2525
.. code-block:: console
@@ -59,3 +59,70 @@ immediately install it, replace ``wheel`` with ``install``. See the
5959

6060
.. _build: https://pypa-build.readthedocs.io/en/stable/
6161
.. _pip: https://pip.pypa.io/
62+
63+
64+
Using a persistent build directory
65+
==================================
66+
67+
By default, ``meson-python`` uses a temporary build directory which is
68+
deleted when the build terminates. A persistent build directory allows
69+
faster incremental builds and to access build logs and intermediate
70+
build artifacts. The ``build-dir`` :ref:`config setting
71+
<reference-config-settings>` instructs ``meson-python`` to use a
72+
user-specified build directory which will not be deleted. For example:
73+
74+
.. tab-set::
75+
76+
.. tab-item:: pypa/build
77+
:sync: key_pypa_build
78+
79+
.. code-block:: console
80+
81+
$ python -m build -Cbuild-dir=build
82+
83+
.. tab-item:: pip
84+
:sync: key_pip
85+
86+
.. code-block:: console
87+
88+
$ python -m pip install . -Cbuild-dir=build
89+
90+
After running this command, the ``build`` directory will contain all
91+
the build artifacts and support files created by ``meson``, ``ninja``
92+
and ``meson-python``. The same build directory can be used by
93+
subsequent invocations of ``meson-python``, avoiding the need to
94+
rebuild the whole project when testing changes during development.
95+
96+
Using a permanent build directory also aids in debugging a failing
97+
build by allowing access to build logs and intermediate build outputs,
98+
including the Meson introspection files and detailed log. The latter
99+
is stored in the ``meson-logs/meson-log.txt`` file in the build
100+
directory and can be useful to diagnose why a build fails at the
101+
project configuration stage. For example, to understand why dependency
102+
detection failed, it is often necessary to look at the ``pkg-config``
103+
or other dependency detection methods output.
104+
105+
Access to detailed logs and intermediate build outputs is particularly
106+
helpful in CI setups where introspecting the build environment is
107+
usually more difficult than on a local system. Therefore, it can be
108+
useful to show the more detailed log files when the CI build step
109+
fails. For example, the following GitHub Actions workflow file snippet
110+
shows the detailed Meson setup log when the build fails:
111+
112+
.. code-block:: yaml
113+
114+
- name: Build the package
115+
run: python -m build --wheel -Cbuild-dir=build
116+
- name: Show meson-log.txt
117+
if: failure()
118+
run: cat build/meson-logs/meson-log.txt
119+
120+
Replacing ``failure()`` with ``always()`` in the code above will
121+
result in the Meson log file always being shown. See the GitHub
122+
Actions documentation__ for more details. Please be aware that the
123+
setup log can become very long for complex projects, and the GitHub
124+
Actions web interface becomes unresponsive when the running job emits
125+
many output lines.
126+
127+
128+
__ https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

docs/reference/config-settings.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ them.
2323
exists and contains a valid Meson build directory setup, the
2424
project will be reconfigured using ``meson setup --reconfigure``.
2525

26-
The same build directory can be used by subsequent invocations of
27-
``meson-python``. This avoids having to rebuild the whole project
28-
when testing changes during development.
29-
3026
For backward compatibility reasons, the alternative ``builddir``
3127
spelling is also accepted.
3228

0 commit comments

Comments
 (0)