Skip to content

Conversation

markmentovai
Copy link
Contributor

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 numpy/meson programs.py:179.

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.
@github-actions github-actions bot added the 36 - Build Build related PR label Oct 20, 2023
@rgommers rgommers added this to the 2.0.0 release milestone Oct 20, 2023
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rgommers rgommers merged commit 0b1484c into numpy:main Oct 20, 2023
@rgommers rgommers added the 09 - Backport-Candidate PRs tagged should be backported label Oct 20, 2023
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants