|
36 | 36 | SYSTEM_IS_WINDOWS = sys.platform.startswith("win") |
37 | 37 |
|
38 | 38 |
|
| 39 | +def default_compiler_directives(): |
| 40 | + return dict(language_level="3", |
| 41 | + binding=True) |
| 42 | + |
| 43 | + |
39 | 44 | class IsalExtension(Extension): |
40 | 45 | """Custom extension to allow for targeted modification.""" |
41 | 46 | pass |
@@ -106,21 +111,22 @@ def build_extension(self, ext): |
106 | 111 | # -fPIC needed for proper static linking |
107 | 112 | ext.extra_compile_args = ["-fPIC"] |
108 | 113 |
|
109 | | - if os.getenv("CYTHON_COVERAGE") is not None: |
110 | | - # Import cython here so python setup.py can be used without |
111 | | - # installing cython. |
112 | | - from Cython.Build import cythonize |
113 | | - # Add cython directives and macros for coverage support. |
114 | | - cythonized_exts = cythonize(ext, compiler_directives=dict( |
115 | | - linetrace=True |
116 | | - )) |
117 | | - for cython_ext in cythonized_exts: |
| 114 | + # Import cython here so python setup.py can be used without |
| 115 | + # installing cython. |
| 116 | + from Cython.Build import cythonize |
| 117 | + compiler_directives = default_compiler_directives() |
| 118 | + line_tracing_enabled = os.getenv("CYTHON_COVERAGE") is not None |
| 119 | + if line_tracing_enabled: |
| 120 | + # Add cython directives for coverage support. |
| 121 | + compiler_directives.update(linetrace=True) |
| 122 | + cythonized_exts = cythonize( |
| 123 | + ext, compiler_directives=compiler_directives) |
| 124 | + |
| 125 | + for cython_ext in cythonized_exts: |
| 126 | + if line_tracing_enabled: |
118 | 127 | cython_ext.define_macros = [("CYTHON_TRACE_NOGIL", "1")] |
119 | | - cython_ext._needs_stub = False |
120 | | - super().build_extension(cython_ext) |
121 | | - return |
122 | | - |
123 | | - super().build_extension(ext) |
| 128 | + cython_ext._needs_stub = False |
| 129 | + super().build_extension(cython_ext) |
124 | 130 |
|
125 | 131 |
|
126 | 132 | # Use a cache to prevent isa-l from being build twice. According to the |
|
0 commit comments