Skip to content

Commit

Permalink
BLD: use meson-native dependency lookup for pybind11
Browse files Browse the repository at this point in the history
This makes use of mesonbuild/meson#11463 to find
pybind11 using the pybind11-config script installed in build isolation.

If that doesn't work, for example the version of Meson is too old, then
we fall back to the previous method of manually running some
introspection code, and no harm is done.
  • Loading branch information
eli-schwartz committed Feb 26, 2023
1 parent 955ec88 commit 8cd823d
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions scipy/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,27 @@ npymath_lib = cc.find_library('npymath', dirs: npymath_path)
npyrandom_lib = cc.find_library('npyrandom', dirs: npyrandom_path)

# pybind11 include directory - needed in several submodules
incdir_pybind11 = run_command(py3,
[
'-c',
'''from os.path import relpath
import pybind11
try:
incdir = relpath(pybind11.get_include())
except Exception:
incdir = pybind11.get_include()
print(incdir)
'''
],
check: true
).stdout().strip()
#
# in meson 1.1.0, this will find the pyproject.toml build-requires version
pybind11_dep = dependency('pybind11', version: '>=2.10.0', required: false, allow_fallback: true)
if not pybind11_dep.found()
incdir_pybind11 = run_command(py3,
[
'-c',
'''from os.path import relpath
import pybind11
try:
incdir = relpath(pybind11.get_include())
except Exception:
incdir = pybind11.get_include()
print(incdir)
'''
],
check: true
).stdout().strip()

pybind11_dep = declare_dependency(include_directories: incdir_pybind11)
pybind11_dep = declare_dependency(include_directories: incdir_pybind11)
endif

# Pythran include directory and build flags
if use_pythran
Expand Down

0 comments on commit 8cd823d

Please sign in to comment.