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

BLD: use meson-native dependency lookup for pybind11 #18058

Merged
merged 1 commit into from Feb 27, 2023

Conversation

eli-schwartz
Copy link
Contributor

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.

@eli-schwartz
Copy link
Contributor Author

@rgommers

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.
@dschmitz89 dschmitz89 added Build issues Issues with building from source, including different choices of architecture, compilers and OS Meson Items related to the introduction of Meson as the new build system for SciPy labels Feb 26, 2023
@rgommers
Copy link
Member

Thanks @eli-schwartz! This LGTM. It is going to intersect with gh-18034 - merge order doesn't matter, but the second PR will have a conflict. Functionality-wise, given that pybind11-config still runs Python code, I think we still have to check for the path from the cross file first.

@eli-schwartz
Copy link
Contributor Author

I think we still have to check for the path from the cross file first.

If a path is specified via a cross file property, it makes sense that that path overrides any mere environment probing (even pkg-config, which doesn't run python code).

That being said, it's very possible to use a native pybind11 to build a cross python extension, since it's a header-only library. So if you're setting up a cross build and pointing to a native pybind11-config, that should work fine.

(But it needs meson 1.1.0, which SciPy cannot guarantee and can reasonably be expected to provide backwards-compatible cross-file based alternatives to.)

'''from os.path import relpath
#
# 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eli-schwartz one question on allow_fallback: true - that doesn't see to do anything, because we don't have a subprojects/pybind11. Is there a reason to add this (allow packagers to add a subproject, just good style, ...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows adding one with meson wrap install pybind11 (no modification of build files is done).

By default, since this is required: false in order to allow for checking via run_command, Meson doesn't know whether you actually want to do subproject fallbacks, maybe it's just supposed to be a disabled feature instead. This kwarg tells meson that it should do fallbacks if it can, anyway, even for an "optional" dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, that makes sense, thanks.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this merged first - in it goes.

@rgommers rgommers merged commit edd8fd2 into scipy:main Feb 27, 2023
@rgommers rgommers added this to the 1.11.0 milestone Feb 27, 2023
@eli-schwartz eli-schwartz deleted the pybind11-dep branch February 27, 2023 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS Meson Items related to the introduction of Meson as the new build system for SciPy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants