BLD: Use the correct Python interpreter when running tempita.py#24971
Merged
rgommers merged 1 commit intonumpy:maintenance/1.26.xfrom Oct 21, 2023
Merged
BLD: Use the correct Python interpreter when running tempita.py#24971rgommers merged 1 commit intonumpy:maintenance/1.26.xfrom
rgommers merged 1 commit intonumpy:maintenance/1.26.xfrom
Conversation
When a program located by find_program is executable directly, meson will execute it. If it is a script, its shebang (#!) line will control which interpreter is used. tempita.py specifies a standard shebang line of #!/usr/bin/env python3, so that python3 can be located by PATH lookup. In cases where python3 as found in the PATH is not correct, such as on systems that have multiple copies of python3 installed when building numpy for one that is not the python3 found by searching PATH, this interpreter will be wrong. When the python3 found by this mechanism doesn't have Cython available, it will cause the numpy build to fail. With the executable bit removed from tempita.py, meson will scan the script when attempting to execute it, locating the shebang line and substituting the appropriate sys.executable. See https://github.com/numpy/meson/blob/22df45a31981874310a78dde0df59a6a7c5ebb29/mesonbuild/programs.py#L179.
Contributor
|
Wouldn't it be more clear to explicitly use the target Python like Line 63 in 0b1484c |
Member
That's a problem for cross-compiling; the shebang is the recommended approach by Meson. I'd like to get rid of the remaining |
Member
|
This is a backport PR, so I'll merge this. Happy to continue the conversation around |
agriyakhetarpal
added a commit
to agriyakhetarpal/scikit-learn
that referenced
this pull request
Sep 9, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of #24970.
When a program located by
find_programis executable directly, meson will execute it. If it is a script, its shebang (#!) line will control which interpreter is used.tempita.pyspecifies a standard shebang line of#!/usr/bin/env python3, so thatpython3can be located byPATHlookup.In cases where
python3as found in thePATHis not correct, such as on systems that have multiple copies ofpython3installed when building numpy for one that is not thepython3found by searchingPATH, this interpreter will be wrong. When thepython3found by this mechanism doesn't have Cython available, it will cause the numpy build to fail.With the executable bit removed from
tempita.py, meson will scan the script when attempting to execute it, locating the shebang line and substituting the appropriatesys.executable. See numpy/mesonprograms.py:179.