diff options
author | Andrew McNulty <amcn102@gmail.com> | 2023-04-24 09:52:28 +0200 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-08-14 20:02:09 -0400 |
commit | c7308076966c1c55bc117ce9f7a7f49ac96acfa6 (patch) | |
tree | 826fcf546090c3a5155c1d730d34033563038d98 /mesonbuild/scripts/python_info.py | |
parent | 9d323020321893093492bc7d538c311c61398a1e (diff) | |
download | meson-c7308076966c1c55bc117ce9f7a7f49ac96acfa6.zip meson-c7308076966c1c55bc117ce9f7a7f49ac96acfa6.tar.gz meson-c7308076966c1c55bc117ce9f7a7f49ac96acfa6.tar.bz2 |
Python: Add 'limited_api' kwarg to extension_module
This commit adds a new keyword arg to extension_module() that enables
a user to target the Python Limited API, declaring the version of the
limited API that they wish to target.
Two new unittests have been added to test this functionality.
Diffstat (limited to 'mesonbuild/scripts/python_info.py')
-rwxr-xr-x | mesonbuild/scripts/python_info.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index 9c3a079..0f7787c 100755 --- a/mesonbuild/scripts/python_info.py +++ b/mesonbuild/scripts/python_info.py @@ -65,6 +65,20 @@ elif sys.version_info < (3, 8, 7): else: suffix = variables.get('EXT_SUFFIX') +limited_api_suffix = None +if sys.version_info >= (3, 2): + try: + from importlib.machinery import EXTENSION_SUFFIXES + limited_api_suffix = EXTENSION_SUFFIXES[1] + except Exception: + pass + +# pypy supports modules targetting the limited api but +# does not use a special suffix to distinguish them: +# https://doc.pypy.org/en/latest/cpython_differences.html#permitted-abi-tags-in-extensions +if '__pypy__' in sys.builtin_module_names: + limited_api_suffix = suffix + print(json.dumps({ 'variables': variables, 'paths': paths, @@ -76,4 +90,5 @@ print(json.dumps({ 'is_venv': sys.prefix != variables['base_prefix'], 'link_libpython': links_against_libpython(), 'suffix': suffix, + 'limited_api_suffix': limited_api_suffix, })) |