File tree 2 files changed +32
-2
lines changed
numpy/core/tests/examples 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Test that third-party extensions that use the Numpy C API can be built with
3
+ * the limited Python C API (see https://docs.python.org/3/c-api/stable.html).
4
+ */
5
+
6
+ #define Py_LIMITED_API 0x03060000
7
+
8
+ #include <Python.h>
9
+ #include <numpy/arrayobject.h>
10
+ #include <numpy/ufuncobject.h>
11
+
12
+ static PyModuleDef moduledef = {
13
+ .m_base = PyModuleDef_HEAD_INIT ,
14
+ .m_name = "example_limited_api"
15
+ };
16
+
17
+ PyMODINIT_FUNC PyInit_example_limited_api (void )
18
+ {
19
+ import_array ();
20
+ import_umath ();
21
+ return PyModule_Create (& moduledef );
22
+ }
Original file line number Diff line number Diff line change 9
9
from setuptools .extension import Extension
10
10
import os
11
11
12
+ include_dirs = [np .get_include ()]
12
13
macros = [("NPY_NO_DEPRECATED_API" , 0 )]
13
14
14
15
checks = Extension (
15
16
"checks" ,
16
17
sources = [os .path .join ('.' , "checks.pyx" )],
17
- include_dirs = [ np . get_include ()] ,
18
+ include_dirs = include_dirs ,
18
19
define_macros = macros ,
19
20
)
20
21
21
- extensions = [checks ]
22
+ example_limited_api = Extension (
23
+ "example_limited_api" ,
24
+ sources = [os .path .join ('.' , "example_limited_api.c" )],
25
+ include_dirs = include_dirs ,
26
+ define_macros = macros ,
27
+ )
28
+
29
+ extensions = [checks , example_limited_api ]
22
30
23
31
setup (
24
32
ext_modules = cythonize (extensions )
You can’t perform that action at this time.
0 commit comments