Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Run f2py's meson backend with the same python that runs f2py #25321

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions numpy/f2py/_backends/_meson.py
HaoZeke marked this conversation as resolved.
Show resolved Hide resolved
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)
HaoZeke marked this conversation as resolved.
Show resolved Hide resolved
py_dep = py.dependency()

incdir_numpy = run_command(py,
Expand Down