-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: add details on default build options used by meson-python #338
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,49 @@ | ||
.. 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 needs to 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 | ||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Let's go through each option and why they are used: | ||
|
||
- meson-python uses a native file, written to the build dir and 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). Users may use ``--native-file`` to pass a second native file to Meson; | ||
Meson will merge contents of both native file, so as long as the | ||
user-provided file does not try to pass a different path for the ``python`` | ||
binary, this will work without a conflict. | ||
- The ``prefix`` and ``platlibdir``/``purelibdir`` options also point Meson at | ||
that same interpreter and the environment in which it is installed. | ||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
``pyproject.toml`` or at build time via the build frontend CLI. | ||
See the :ref:`how-to-guides-meson-args` page for examples of both methods. |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible improvement:
We could split the paragraph here and also document why we might choose to override the defaults. I wrote about the reasoning in #325 (comment).
We could also note that the options we do need to set are mostly for build/installation details that should not be relevant to the user. The only exception is the native file, but the user should be able to override the parts of it that make sense (IIRC everything but the Python interpreter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep
meson install
I would much prefer if we would get rid of the--prefix
and--python.{plat,pure}lib
options and use the$DESTDIR
environment variable pointing to somewhere in/tmp
instead. This would have the additional benefit of putting the installation directory on tmpfs, with possible significant speedups when building large wheels.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I already have in a fair amount of detail.
I'll see if I should add a few more words of clarification, but thought it was pretty clear already.
That sounds potentially useful. Let's cross that bridge when we get to it I'd say; this PR adds docs for the current state of things, and if/when we add
$DESTDIR
they can be changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked it in more detail, and it's effectively the same as what I already have in this PR: "because Meson defaults to values that are appropriate for development, while the main purpose of meson-python is to build release artifacts."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is even a question, is it 🤣? Those options and
DESTDIR
serve two different purposes. We only set those options for the heuristics, so they can be removed now.Regarding
DESTDIR
, we already set it to a subdirectory ofworking_dir
, which currently when using the PEP 517 hooks is always set bytempfile.TemporaryDirectory
(inwith_temp_working_dir
), so isn't that true already?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The working dir is created inside the project directory, thus it is on the same filesystem as the project sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right 😅. IIRC I did that to make things work properly for packagers by default, where access to
/tmp
might be a bit tricky. We can consider changing the default, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this comment thread open, because it seems like useful info. It doesn't apply to this PR directly though; it's discussion of a potential future design change. If that materializes, the docs can simply be updated.