Skip to content

Commit

Permalink
Merge pull request numpy#25321 from stefanor/f2py-meson-python-exe
Browse files Browse the repository at this point in the history
MAINT: Run f2py's meson backend with the same python that runs f2py
  • Loading branch information
HaoZeke authored Dec 8, 2023
2 parents 35b14fe + 306600b commit a0ec186
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 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 All @@ -45,6 +47,7 @@ def __init__(
self.libraries_substitution,
]
self.build_type = build_type
self.python_exe = python_exe

def meson_build_template(self) -> str:
if not self.build_template_path.is_file():
Expand All @@ -59,6 +62,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 +142,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 a0ec186

Please sign in to comment.