Skip to content

Commit b541b6d

Browse files
rgommersdnicolodi
authored andcommitted
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 b541b6d

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

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

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