-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
python: add limited_api
kwarg to find_installation()
#14176
Open
lgarrison
wants to merge
6
commits into
mesonbuild:master
Choose a base branch
from
lgarrison:python-limited-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To support libraries that target the Python Limited API but are not themselves Python extensions, we add a `limited_api` kwarg to find_installation. This follows the example of the `pure` kwarg.
`python_dependency` objects now hold a `limited_api` value and accept it as a kwarg in `python_installation.dependency()`. By default, the value is inherited from the `python_installation` but can be overridden. If `limited_api` is set, the appropriate `-DPy_LIMITED_API` hex define is propagated to compile targets.
…i` value internally via the dependency Now that dependencies can propagate the `limited_api` define to targets, let the `extension_module`'s internal dependency handle that. From the user's point of view, nothing about the API has changed, except that if `find_installation(limited_api: ...)` was used, then `extension_module` will now inherit that value by default (but can override it).
…pendency` Check that extension_modules and dependencies inherit the installation's limited_api value by default but can override it. Also test the end-to-end case of compiling a library and linking it with an extension, both compiled against the Limited API. This is similar to how nanobind is used.
4a06207
to
452c0f5
Compare
eli-schwartz
reviewed
Feb 5, 2025
Instead of using the string `'inherit'`, let's just use `None` as the sentinel value for `limited_api` to mean the same thing.
As with the other limited API compiler args, we can move the link args specializations for Windows from the extension module to the upstream dependency.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #13824.
To recap: we'd like libraries (like nanobind) to be able to target the Python Limited API in addition to extensions. Basically, we'd like this to work:
Right now, this isn't possible because
limited_api
is only an arg toextension_module
. This PR makes it an arg tofind_installation
anddependency
, too. If theextension_module
ordependency
value isn't specified, it is inherited fromfind_installation
by default. Making it an arg todependency
isn't strictly necessary, but it does make it symmetrical withextension_module
.Before I update the documentation, I wanted to open the PR to get feedback and make sure CI is passing.