Skip to content

Commit

Permalink
Run f2py's meson backend with the same python that ran f2py
Browse files Browse the repository at this point in the history
On Debian, we sometimes have multiple Python 3 versions in the archive.
When using f2py3.X, I'd expect meson to run with the same python, not
the default python.

Not sure how far up the stack this should come from, I kept it simple
for this PR, if someone has better ideas, they can direct me.
  • Loading branch information
stefanor committed Dec 6, 2023
1 parent bcb3463 commit 20acedf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions numpy/f2py/_backends/_meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import errno
import shutil
import subprocess
import sys
from pathlib import Path

from ._backend import Backend
Expand All @@ -27,6 +28,7 @@ def __init__(
linker_args: list[str],
c_args: list[str],
build_type: str,
python_exe: str,
):
self.modulename = modulename
self.build_template_path = (
Expand Down Expand Up @@ -59,6 +61,7 @@ def meson_build_template(self) -> str:
def initialize_template(self) -> None:
self.substitutions["modulename"] = self.modulename
self.substitutions["buildtype"] = self.build_type
self.substitutions["python"] = self.python_exe

def sources_substitution(self) -> None:
indent = " " * 21
Expand Down Expand Up @@ -138,6 +141,7 @@ def write_meson_build(self, build_dir: Path) -> None:
self.flib_flags,
self.fc_flags,
self.build_type,
sys.executable,
)
src = meson_template.generate_meson_build()
Path(build_dir).mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion numpy/f2py/_backends/meson.build.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project('${modulename}',
])
fc = meson.get_compiler('fortran')

py = import('python').find_installation(pure: false)
py = import('python').find_installation('${python}', pure: false)
py_dep = py.dependency()

incdir_numpy = run_command(py,
Expand Down

0 comments on commit 20acedf

Please sign in to comment.