-
Notifications
You must be signed in to change notification settings - Fork 69
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
ENH: fix support for Python limited API / stable ABI wheels #451
Conversation
Documentation is still missing. |
19e40fd
to
48e87a0
Compare
ab0d8b3
to
4700a3f
Compare
I've added the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dnicolodi, this looks quite good and this is a very nice new feature.
My main question is about the added test case: it seems to demonstrate that the limited_api
setting in pyproject.toml
cannot be set correctly if there is a build option which has the effect of toggling between the limited API and the regular C API. This should be rare, but it is conceivable.
In such a case, I think the answer is that the setting in pyproject.toml
should be overridden via a CLI flag in order to not have the build fail, so something like:
pip install . -C-Dextra=true -C--no-limited-api
However, we don't have a flag like --no-limited-api
that meson-python
will use to override the pyproject.toml
setting. Do you think that's needed, or can it be left for later because no one needs this, and we may never need it? Or is the answer to just patch pyproject.toml
?
The test is somehow a contrived example that I clobbered together to do not have to replicate the package for the two test cases. I don't think doing something like that in a real package is realistic. I also think that the use of the limited API is still relatively rare, thus I'll favor keeping this simple for now and add features if the need arise. I have the impression that having Python packages with configurable options and components is a rare exception, as the tooling for Python packaging does not make that easy (for example, there is no way to distinguish between versions of the same package built with different options). I think, in the context of Python packages, Meson options are almost exclusively used for enabling the build (ie, pointing at external dependencies, or switching between alternative implementations used on different platforms) more than enabling or disabling features. I think that using or not the limited API is a choice of the package developers. However, Meson has a configuration options to disable the use of the limited API. One thing we could do is to check whether the option is passed to Meson, and override the |
+1, good to keep it simple. |
For a bit of context, during the development of the limited API support in meson, o recommended the addition of that option toggle based purely on the notion that it would be interesting to ISVs like a Linux distro that don't use wheels except as an unavoidable side effect of build backends requiring them. They manually construct their own distro package manager archive with fully resolved contents pointing to a exact python version and rebuild from source regardless of "limited API or regular extensions", so disabling the limited API define is a free optimization. What are the downsides of an inaccurate wheel tag for purely local builds with an immediate install? |
Ah, I also noticed for the first time that
As long as they are guaranteed to stay local, nothing I guess. But producing |
Hmm, then maybe you can just check the value of that setting from the json introspection files created in the builddir? |
When building wheel for the stable API, meson-python checks that the extension modules filenames suffixes actually match what is expected for the stable ABI. Therefore not setting The value of the option is easy enough to check. The hard part is the UI. How should the thing be presented to the user? In other words, if |
I guess that depends on how you view the setting. Is it:
What I understood from:
is that you want the meson-python option to act as a hint, not a requirement. Therefore if the meson option |
2fa1b53
to
c36d14c
Compare
I've implemented it exactly like that now, and updated the documentation. |
This mostly serves the purpose of testing the limited API support.
The cast was anyhow to an incorrect type.
Meson gained support for building Python extension modules targeting the Python limited API, therefore it is time for meson-python to properly support tagging the build wheels as targeting the stable ABI. Unfortunately there isn't a reliable and cross-platform way to detect when extension modules are build for the limited API. Therefore, we need to add an explicit "limited-api" configuration option in the [tool.meson-python] section in pyproject.toml.
Group similar tests together and use similar constructs to skip tests on platforms not supporting the tested features. This made it evident that we are skipping a valid test on macOS. Fix that.
The Cygwin CI job isn't happy with the new
|
Cygwin is always funny, and given this result, I don't know what |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All green now and looks great, in it goes. Thanks @dnicolodi!
Meson gained support for building Python extension modules targeting the Python limited API, therefore it is time for meson-python to properly support tagging the build wheels as targeting the stable ABI.
Unfortunately there isn't a reliable and cross-platform way to detect when extension modules are build for the limited API. Therefore, we need to add an explicit "limited-api" configuration option in the [tool.meson-python] section in pyproject.toml.