1
PYTHON setup.py build_ext --inplace
5
######## setup.py ########
7
from Cython.Build.Dependencies import cythonize
8
from setuptools import setup, Extension
10
setup(ext_modules = cythonize([
11
Extension("test_on", ["test_on.pyx"]),
12
Extension("test_off", ["test_off.pyx"]),
13
Extension("test_runtime", ["test_runtime.pyx"]),
14
Extension("test_default", ["test_default.pyx"]),
15
Extension("test_contradicting_macros", ["test_contradicting_macros.pyx"]),
19
setup(ext_modules = cythonize([
20
Extension("test_options_on", ["test_options_on.pyx"]),
21
Extension("test_options_on_overridden", ["test_options_on_overridden.pyx"]),
23
c_line_in_traceback = True,
26
setup(ext_modules = cythonize([
27
Extension("test_options_off", ["test_options_off.pyx"]),
28
Extension("test_options_off_overridden1", ["test_options_off_overridden1.pyx"]),
29
Extension("test_options_off_overridden2", ["test_options_off_overridden2.pyx"]),
31
c_line_in_traceback = False,
35
####### test_on.pyx ###############
36
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK=1
38
include "should_be_on.pxi"
40
####### test_off.pyx ###############
41
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK=0
43
include "should_be_off.pxi"
45
####### test_runtime.pyx ###############
47
include "should_be_runtime.pxi"
49
####### test_runtime.pyx ##############
50
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK_RUNTIME=1
52
include "should_be_runtime.pxi"
54
####### test_default.pyx ##############
56
include "should_be_off.pxi"
58
####### test_options_on.pyx ########
60
include "should_be_runtime.pxi"
62
####### test_options_off.pyx ########
64
include "should_be_off.pxi"
66
####### test_options_off_overridden1.pyx #######
67
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK=1
69
include "should_be_on.pxi"
71
####### test_options_off_overridden2.pyx #######
72
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK_RUNTIME=1
74
include "should_be_runtime.pxi"
76
####### test_options_on_overridden.pyx #######
77
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK=0
79
include "should_be_off.pxi"
81
####### test_contradicting_macros.pyx #######
82
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK_RUNTIME=1
83
# distutils: define_macros=CYTHON_CLINE_IN_TRACEBACK=0
85
include "should_be_off.pxi"
88
####### should_be_on.pxi #########
95
except Exception as e:
96
helpers.validate_cline_in_traceback(e.__traceback__)
98
####### should_be_off.pxi #########
105
except Exception as e:
106
helpers.validate_no_cline_in_traceback(e.__traceback__)
108
####### should_be_runtime.pxi #########
116
except Exception as e:
117
helpers.validate_no_cline_in_traceback(e.__traceback__)
119
cython_runtime.cline_in_traceback = True
122
except Exception as e:
123
helpers.validate_cline_in_traceback(e.__traceback__)
125
cython_runtime.cline_in_traceback = False
128
except Exception as e:
129
helpers.validate_no_cline_in_traceback(e.__traceback__)
132
####### helpers.py ##############
137
cline_re = re.compile(r"[(]\w*[.]c:\d*[)]")
139
def validate_cline_in_traceback(tb):
140
formatted = traceback.format_tb(tb)
141
assert cline_re.search(formatted[0]), formatted
143
def validate_no_cline_in_traceback(tb):
144
formatted = traceback.format_tb(tb)
145
assert not cline_re.search(formatted[0]), formatted
148
####### run_all_tests.py #########
150
import test_on; test_on.run()
151
import test_off; test_off.run()
152
import test_runtime; test_runtime.run()
153
import test_default; test_default.run()
154
import test_options_on; test_options_on.run()
155
import test_options_off; test_options_off.run()
156
import test_options_off_overridden1; test_options_off_overridden1.run()
157
import test_options_off_overridden2; test_options_off_overridden2.run()
158
import test_options_on_overridden; test_options_on_overridden.run()
159
import test_contradicting_macros; test_contradicting_macros.run()