|
8 | 8 | Passing arguments to Meson_
|
9 | 9 | ***************************
|
10 | 10 |
|
11 |
| - |
12 | 11 | .. todo::
|
13 | 12 |
|
14 | 13 | - Explain how you can add extra Meson arguments via ``pyproject.toml``
|
15 | 14 | - Explain how you can add extra Meson arguments via the build config
|
16 | 15 | settings
|
17 | 16 | - Mention the order in which Meson arguments are added, and how it affect
|
18 | 17 | Meson
|
| 18 | + |
| 19 | +Advanced meson options can be accessed by specifying extra arguments to the individual meson comands: |
| 20 | + |
| 21 | + - meson dist: https://mesonbuild.com/Commands.html#dist |
| 22 | + - meson setup: https://mesonbuild.com/Commands.html#setup |
| 23 | + - meson compile: https://mesonbuild.com/Commands.html#compile |
| 24 | + - meson install: https://mesonbuild.com/Commands.html#install |
| 25 | + |
| 26 | +These arguments can be added to the project via the project's ``pyproject.toml``: |
| 27 | + |
| 28 | +.. code-block:: console |
| 29 | +
|
| 30 | + [tool.meson-python.args] |
| 31 | + dist = ['dist-argument_1','dist-argument_2', '...']] |
| 32 | + setup = ['setup-argument_1','setup-argument_2', '...']] |
| 33 | + compile = ['compile-argument_1','compile-argument_2', '...']] |
| 34 | + install = ['install-argument_1','install-argument_2', '...']] |
| 35 | +
|
| 36 | +.. admonition:: All four categories must exist |
| 37 | + :class: attention |
| 38 | + |
| 39 | + Currently all four option categories (dist, setup, compile and install) must be present in the [tool.meson-python.args] section, even if no arguments are supplied (empty list: []) |
| 40 | + |
| 41 | +Or the build config settings: |
| 42 | + |
| 43 | +.. code-block:: console |
| 44 | +
|
| 45 | + ? |
| 46 | + |
| 47 | +Example 1: set the default libraries to "static" |
| 48 | +================================================ |
| 49 | + |
| 50 | +Set the target default libraries to "static" in the pyproject.toml |
| 51 | + |
| 52 | +.. code-block:: console |
| 53 | +
|
| 54 | + [tool.meson-python.args] |
| 55 | + dist = [] |
| 56 | + setup = ["--default-library=static"] |
| 57 | + compile = [] |
| 58 | + install = [] |
| 59 | + |
| 60 | +Or the build config settings: |
| 61 | + |
| 62 | +.. code-block:: console |
| 63 | +
|
| 64 | + ? |
| 65 | + |
| 66 | +
|
| 67 | +Example 2: use meson install_tags for selective installs |
| 68 | +======================================================== |
| 69 | + |
| 70 | +It is now (meson-python >= 0.13) possible to use meson install_tags to select which targets are installed into the binary wheels. |
| 71 | + |
| 72 | +.. admonition:: Meson installation tags |
| 73 | + :class: seealso |
| 74 | + |
| 75 | + Each meson target has a default install_tag (e.g. 'runtime' for shared libraries and 'devel' for headers.). Using "meson install --tags=tag1,tag2,..." will cause meson to only install the targets tagges with any of the specified tags. The default tag of each target can be overwritten using the target's "install_tag" option. Ffor more information refer mesons documentation in installation-tags: https://mesonbuild.com/Installing.html#installation-tags |
| 76 | + |
| 77 | +The following code (in pyproject.toml) causes meson-python to only install targets tagged with 'runtime' or 'python-runtime') into the binary wheel (ignoring e.g. c++ headers): |
| 78 | + |
| 79 | +.. code-block:: console |
| 80 | +
|
| 81 | + [tool.meson-python.args] |
| 82 | + dist = [] |
| 83 | + setup = [] |
| 84 | + compile = [] |
| 85 | + install = ['--tags=runtime,python-runtime'] |
| 86 | + |
| 87 | +Or the build config settings: |
| 88 | + |
| 89 | +.. code-block:: console |
19 | 90 |
|
| 91 | + ? |
| 92 | + |
20 | 93 |
|
21 | 94 | .. _Meson: https://github.com/mesonbuild/meson
|
0 commit comments