diff --git a/numpy/f2py/_backends/_meson.py b/numpy/f2py/_backends/_meson.py index 7956fc64b671..7cf08446e863 100644 --- a/numpy/f2py/_backends/_meson.py +++ b/numpy/f2py/_backends/_meson.py @@ -4,6 +4,7 @@ import errno import shutil import subprocess +import sys from pathlib import Path from ._backend import Backend @@ -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 = ( @@ -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 @@ -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) diff --git a/numpy/f2py/_backends/meson.build.template b/numpy/f2py/_backends/meson.build.template index 65e3ecb19c30..52e34634493a 100644 --- a/numpy/f2py/_backends/meson.build.template +++ b/numpy/f2py/_backends/meson.build.template @@ -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,