Skip to content

Commit a34aad2

Browse files
committed
DOC: add documentation for meson-args.rst
This is a draft for the (how to) meson-args documentation
1 parent 6d96b3e commit a34aad2

File tree

1 file changed

+120
-1
lines changed

1 file changed

+120
-1
lines changed

docs/how-to-guides/meson-args.rst

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
Passing arguments to Meson_
99
***************************
1010

11-
1211
.. todo::
1312

1413
- Explain how you can add extra Meson arguments via ``pyproject.toml``
@@ -17,5 +16,125 @@ Passing arguments to Meson_
1716
- Mention the order in which Meson arguments are added, and how it affect
1817
Meson
1918

19+
Advanced meson options can be accessed by specifying extra arguments to the
20+
individual meson commands:
21+
22+
- meson dist: https://mesonbuild.com/Commands.html#dist
23+
- meson setup: https://mesonbuild.com/Commands.html#setup
24+
- meson compile: https://mesonbuild.com/Commands.html#compile
25+
- meson install: https://mesonbuild.com/Commands.html#install
26+
27+
These arguments can be added to the project by adding a section
28+
to the project's ``pyproject.toml``, or as arguments when building
29+
the package using the :ref:`build config settings<how-to-guides-config-settings>`
30+
31+
.. tab-set::
32+
33+
.. tab-item:: pyproject.toml
34+
:sync: key_pyproject_toml
35+
36+
.. code-block::
37+
38+
[tool.meson-python.args]
39+
dist = ['dist-argument_1', 'dist-argument_2', '...']
40+
setup = ['setup-argument_1', 'setup-argument_2', '...']
41+
compile = ['compile-argument_1', 'compile-argument_2', '...']
42+
install = ['install-argument_1', 'install-argument_2', '...']
43+
44+
.. tab-item:: pypa/buid
45+
:sync: key_pypa_build
46+
47+
.. code-block:: console
48+
49+
$ python -m build -Cdist-args="args" \
50+
-Csetup-args="args" \
51+
-Ccompile-args="args" \
52+
-Cinstall-args="args" .
53+
54+
.. tab-item:: pip
55+
:sync: key_pip
56+
57+
.. code-block:: console
58+
59+
$ python -m pip --config-settings=dist-args="args" \
60+
--config-settings=setup-args="args" \
61+
--config-settings=compile-args="args" \
62+
--config-settings=install-args="args" .
63+
64+
65+
Example 1: set the default libraries to *static*
66+
================================================
67+
68+
Set the target default libraries to "static"
69+
70+
.. tab-set::
71+
72+
.. tab-item:: pyproject.toml
73+
:sync: key_pyproject_toml
74+
75+
.. code-block:: console
76+
77+
[tool.meson-python.args]
78+
dist = []
79+
setup = ['--default-library=static']
80+
compile = []
81+
install = []
82+
83+
.. tab-item:: pypa/build
84+
:sync: key_pypa_build
85+
86+
.. code-block:: console
87+
88+
$ python -m build -Csetup-args="--default-library=static" .
89+
90+
.. tab-item:: pip
91+
:sync: key_pip
92+
93+
.. code-block:: console
94+
95+
$ python -m pip --config-settings=setup-args="--default-library=static" .
96+
97+
98+
Example 2: use meson install_tags for selective installs
99+
========================================================
100+
101+
Meson install_tags can be used (since ``meson-python`` >= 0.13) to select which
102+
targets are installed into the binary wheels. This example causes meson-python
103+
to only install targets tagged with ``runtime`` or ``python-runtime``) into the
104+
binary wheel (ignoring e.g. C++ headers):
105+
106+
.. tab-set::
107+
108+
.. tab-item:: pyproject.toml
109+
:sync: key_pyproject_toml
110+
111+
.. code-block:: console
112+
113+
[tool.meson-python.args]
114+
dist = []
115+
setup = []
116+
compile = []
117+
install = ['--tags=runtime,python-runtime']
118+
119+
.. tab-item:: pypa/build
120+
:sync: key_pypa_build
121+
122+
.. code-block:: console
123+
124+
$ python -m build -install-args="--tags=runtime,python-runtime" .
125+
126+
.. tab-item:: pip
127+
:sync: key_pip
128+
129+
.. code-block:: console
130+
131+
$ python -m pip --config-settings=install-args="--tags=runtime,python-runtime" .
132+
133+
134+
.. admonition:: Meson installation tags
135+
:class: seealso
136+
137+
Each meson target has a default install_tag (e.g. ``runtime`` for shared libraries and ``devel`` for headers.). Calling ``meson install --tags=tag1,tag2,...`` will cause meson to only install the targets tagged with any of the specified tags. The default tag of each target can be overwritten using the target's "install_tag" option. For more information refer mesons documentation in installation-tags: https://mesonbuild.com/Installing.html#installation-tags
138+
20139

21140
.. _Meson: https://github.com/mesonbuild/meson

0 commit comments

Comments
 (0)