cython
1# These tests aren't perfect because they just mislead some of the Cython
2# code about the build environment - they don't actually manage to
3# simulate getting the environment wrong in the Python headers (which
4# is potentially a more dramatic problem).
5
6PYTHON setup.py build_ext --inplace
7PYTHON test.py
8
9##################### setup.py #########################
10
11
12from setuptools import setup
13from Cython.Build import cythonize
14
15setup(
16ext_modules = cythonize("*.pyx")
17)
18
19##################### test.py ###########################
20
21import sys
22
23if sys.implementation.name != 'cpython':
24exit(0)
25
26if sys.version_info < (3, 8):
27try:
28import debug
29assert False, "Failed 'debug' test"
30except ImportError:
31pass
32
33if sys.version_info >= (3, 13):
34try:
35import freethread
36assert False, "Failed 'freethread' test"
37except ImportError:
38pass
39
40try:
41import trace
42assert False, "Failed 'trace' test"
43except ImportError:
44pass
45
46##################### debug.pyx #########################
47
48cdef extern from *:
49"""
50#ifdef Py_DEBUG
51#undef Py_DEBUG
52#else
53#define Py_DEBUG
54#endif
55"""
56
57something = 1
58
59##################### freethread.pyx ###################
60
61cdef extern from *:
62"""
63#ifdef Py_GIL_DISABLED
64#undef Py_GIL_DISABLED
65#else
66#define Py_GIL_DISABLED
67#endif
68"""
69
70something = 1
71
72#################### trace.pyx #########################
73
74cdef extern from *:
75"""
76#ifdef Py_TRACE_REFS
77#undef Py_TRACE_REFS
78#else
79#define Py_TRACE_REFS
80#endif
81"""
82
83something = 1
84