BLD: Use the correct Python interpreter when running tempita.py#24970
Merged
rgommers merged 1 commit intonumpy:mainfrom Oct 20, 2023
Merged
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.
rgommers
approved these changes
Oct 20, 2023
Member
rgommers
left a comment
There was a problem hiding this comment.
Thanks @markmentovai. I can't remember how this script ended up with its executable bit set, but it seems wrong indeed. No other scripts have that, nor the tempita.py script in scipy.
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.
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.