summaryrefslogtreecommitdiff
path: root/test cases/python/10 extmodule limited api disabled
diff options
context:
space:
mode:
authorAndrew McNulty <amcn102@gmail.com>2023-04-24 09:52:28 +0200
committerEli Schwartz <eschwartz93@gmail.com>2023-08-14 20:02:09 -0400
commitc7308076966c1c55bc117ce9f7a7f49ac96acfa6 (patch)
tree826fcf546090c3a5155c1d730d34033563038d98 /test cases/python/10 extmodule limited api disabled
parent9d323020321893093492bc7d538c311c61398a1e (diff)
downloadmeson-c7308076966c1c55bc117ce9f7a7f49ac96acfa6.tar.gz
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 'test cases/python/10 extmodule limited api disabled')
-rw-r--r--test cases/python/10 extmodule limited api disabled/meson.build10
-rw-r--r--test cases/python/10 extmodule limited api disabled/module.c17
2 files changed, 27 insertions, 0 deletions
diff --git a/test cases/python/10 extmodule limited api disabled/meson.build b/test cases/python/10 extmodule limited api disabled/meson.build
new file mode 100644
index 000000000..42cd6186c
--- /dev/null
+++ b/test cases/python/10 extmodule limited api disabled/meson.build
@@ -0,0 +1,10 @@
+project('Python limited api disabled', 'c',
+ default_options : ['buildtype=release', 'werror=true', 'python.allow_limited_api=false'])
+
+py_mod = import('python')
+py = py_mod.find_installation()
+
+module = py.extension_module('my_module',
+ 'module.c',
+ limited_api: '3.7',
+)
diff --git a/test cases/python/10 extmodule limited api disabled/module.c b/test cases/python/10 extmodule limited api disabled/module.c
new file mode 100644
index 000000000..a5d3a87ab
--- /dev/null
+++ b/test cases/python/10 extmodule limited api disabled/module.c
@@ -0,0 +1,17 @@
+#include <Python.h>
+
+#if defined(Py_LIMITED_API)
+#error "Py_LIMITED_API's definition by Meson should have been disabled."
+#endif
+
+static struct PyModuleDef my_module = {
+ PyModuleDef_HEAD_INIT,
+ "my_module",
+ NULL,
+ -1,
+ NULL
+};
+
+PyMODINIT_FUNC PyInit_my_module(void) {
+ return PyModule_Create(&my_module);
+}