Debian Codegraph @

tests/run/freethreading_compatible.srctree

raw
1 UNSET PYTHON_GIL
2 UNSET CFLAGS
3 PYTHON setup.py build_ext --inplace
4 PYTHON -c "import default; default.test()"
5 PYTHON -c "import compatible; compatible.test()"
6 PYTHON -c "import incompatible; incompatible.test()"
7 PYTHON -c "import default_single; default_single.test()"
8 PYTHON -c "import compatible_single; compatible_single.test()"
9 PYTHON -c "import incompatible_single; incompatible_single.test()"
10
11 ######## setup.py ########
12
13 from Cython.Build import cythonize
14 from setuptools import setup, Extension
15
16 ext_modules = [
17 Extension('default', ['default.py']),
18 Extension('compatible', ['compatible.py']),
19 Extension('incompatible', ['incompatible.py']),
20 Extension('default_single',
21 ['default_single.py'],
22 define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
23 Extension('compatible_single',
24 ['compatible_single.py'],
25 define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
26 Extension('incompatible_single',
27 ['incompatible_single.py'],
28 define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
29 ]
30
31 setup(ext_modules=cythonize(ext_modules))
32
33 ######## default.py ########
34
35 def test():
36 import sys
37 import sysconfig
38 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
39 return
40 assert sys._is_gil_enabled()
41
42 ######## compatible.py ########
43
44 # cython: freethreading_compatible=True
45
46 def test():
47 import sys
48 import sysconfig
49 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
50 return
51 assert not sys._is_gil_enabled()
52
53 ######## incompatible.py ########
54
55 # cython: freethreading_compatible=False
56
57 def test():
58 import sys
59 import sysconfig
60 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
61 return
62 assert sys._is_gil_enabled()
63
64 ######## default_single.py ########
65
66 def test():
67 import sys
68 import sysconfig
69 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
70 return
71 assert sys._is_gil_enabled()
72
73 ######## compatible_single.py ########
74
75 # cython: freethreading_compatible=True
76
77 def test():
78 import sys
79 import sysconfig
80 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
81 return
82 assert not sys._is_gil_enabled()
83
84 ######## incompatible_single.py ########
85
86 # cython: freethreading_compatible=False
87
88 def test():
89 import sys
90 import sysconfig
91 if not sysconfig.get_config_var("Py_GIL_DISABLED"):
92 return
93 assert sys._is_gil_enabled()