-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: add details on default build options used by meson-python
This follows up on the `n_debug` default added in gh-325, documents all other default options and they are used, as well as improves the page on using `pyproject.toml` settings.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.. SPDX-FileCopyrightText: 2023 The meson-python developers | ||
.. | ||
.. SPDX-License-Identifier: MIT | ||
.. _explanations-default-options: | ||
|
||
********************* | ||
Default build options | ||
********************* | ||
|
||
Meson offers many `built-in options <https://mesonbuild.com/Builtin-options.html>`__, | ||
and in the vast majority of cases those have good defaults. There are a couple | ||
of cases however where ``meson-python`` either is forced or chooses to override | ||
those with its own defaults. To view what those are for the version of | ||
``meson-python`` you have installed, look at the *User defined options* section | ||
of the output during the configure stage of the build (e.g., by running | ||
``python -m build --wheel``). This will look something like: | ||
|
||
.. code-block:: text | ||
User defined options | ||
Native files : /home/username/code/project/.mesonpy-native-file.ini | ||
debug : false | ||
optimization : 2 | ||
prefix : /home/username/mambaforge/envs/project-dev | ||
python.platlibdir: /home/username/mambaforge/envs/project-dev/lib/python3.10/site-packages | ||
python.purelibdir: /home/username/mambaforge/envs/project-dev/lib/python3.10/site-packages | ||
b_ndebug : if-release | ||
Let's go through each option and why they are used: | ||
|
||
- meson-python uses a native file, named ``.mesonpy-native-file.ini`` in order | ||
to point Meson at the correct ``python`` interpreter to use (the same one for | ||
which ``meson-python`` was installed). This is necessary, because Meson may | ||
otherwise look for the first Python interpreter on the PATH (usually the same | ||
one, but not always the case). | ||
- The ``prefix`` and ``platlibdir``/``purelibdir`` options also point Meson at | ||
that same interpreter and the environment in which it is installed. | ||
- The ``debug``, ``optimization`` and ``b_ndebug`` options are overridden, | ||
because Meson defaults to values that are appropriate for development, while | ||
the main purpose of meson-python is to build release artifacts. | ||
|
||
It is possible to override these defaults, either permanently in your project | ||
or at build time. For example, to build a wheel with debug symbols, use: | ||
|
||
.. code-block:: bash | ||
$ python -m build -Csetup-args=-Ddebug=true | ||
And to override all debug and optimization settings permanently, add this to | ||
your ``pyproject.toml`` file: | ||
|
||
.. code-block:: toml | ||
[tool.meson-python.args] | ||
setup = ['-Ddebug=true', '-Doptimization=0', '-Db_ndebug=false'] | ||
dist = [] | ||
compile = [] | ||
install = [] | ||
For more details on overriding build options at build time see | ||
:ref:`here <reference-config-settings>`, and in ``pyproject.toml`` see | ||
:ref:`here <reference-pyproject-settings>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters