cython

Форк
0
/
freethreading_compatible.srctree 
92 строки · 2.4 Кб
1
UNSET PYTHON_GIL
2
PYTHON setup.py build_ext --inplace
3
PYTHON -c "import default; default.test()"
4
PYTHON -c "import compatible; compatible.test()"
5
PYTHON -c "import incompatible; incompatible.test()"
6
PYTHON -c "import default_single; default_single.test()"
7
PYTHON -c "import compatible_single; compatible_single.test()"
8
PYTHON -c "import incompatible_single; incompatible_single.test()"
9

10
######## setup.py ########
11

12
from Cython.Build import cythonize
13
from setuptools import setup, Extension
14

15
ext_modules = [
16
    Extension('default', ['default.py']),
17
    Extension('compatible', ['compatible.py']),
18
    Extension('incompatible', ['incompatible.py']),
19
    Extension('default_single',
20
              ['default_single.py'],
21
              define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
22
    Extension('compatible_single',
23
              ['compatible_single.py'],
24
              define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
25
    Extension('incompatible_single',
26
              ['incompatible_single.py'],
27
              define_macros=[('CYTHON_PEP489_MULTI_PHASE_INIT', '0')]),
28
]
29

30
setup(ext_modules=cythonize(ext_modules))
31

32
######## default.py ########
33

34
def test():
35
    import sys
36
    import sysconfig
37
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
38
        return
39
    assert sys._is_gil_enabled()
40

41
######## compatible.py ########
42

43
# cython: freethreading_compatible=True
44

45
def test():
46
    import sys
47
    import sysconfig
48
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
49
        return
50
    assert not sys._is_gil_enabled()
51

52
######## incompatible.py ########
53

54
# cython: freethreading_compatible=False
55

56
def test():
57
    import sys
58
    import sysconfig
59
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
60
        return
61
    assert sys._is_gil_enabled()
62

63
######## default_single.py ########
64

65
def test():
66
    import sys
67
    import sysconfig
68
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
69
        return
70
    assert sys._is_gil_enabled()
71

72
######## compatible_single.py ########
73

74
# cython: freethreading_compatible=True
75

76
def test():
77
    import sys
78
    import sysconfig
79
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
80
        return
81
    assert not sys._is_gil_enabled()
82

83
######## incompatible_single.py ########
84

85
# cython: freethreading_compatible=False
86

87
def test():
88
    import sys
89
    import sysconfig
90
    if not sysconfig.get_config_var("Py_GIL_DISABLED"):
91
        return
92
    assert sys._is_gil_enabled()
93

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.