Skip to content

Commit f1b21a2

Browse files
committed
Set compiler_directives per file
1 parent 700dfe7 commit f1b21a2

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

setup.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
SYSTEM_IS_WINDOWS = sys.platform.startswith("win")
3737

3838

39-
def default_compiler_directives():
40-
return dict(language_level="3",
41-
binding=True)
42-
43-
4439
class IsalExtension(Extension):
4540
"""Custom extension to allow for targeted modification."""
4641
pass
@@ -110,23 +105,20 @@ def build_extension(self, ext):
110105
"include")]
111106
# -fPIC needed for proper static linking
112107
ext.extra_compile_args = ["-fPIC"]
113-
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:
108+
if os.getenv("CYTHON_COVERAGE") is not None:
109+
# Import cython here so python setup.py can be used without
110+
# installing cython.
111+
from Cython.Build import cythonize
112+
# Add cython directives and macros for coverage support.
113+
cythonized_exts = cythonize(ext, compiler_directives=dict(
114+
linetrace=True
115+
))
116+
for cython_ext in cythonized_exts:
127117
cython_ext.define_macros = [("CYTHON_TRACE_NOGIL", "1")]
128-
cython_ext._needs_stub = False
129-
super().build_extension(cython_ext)
118+
cython_ext._needs_stub = False
119+
super().build_extension(cython_ext)
120+
return
121+
super().build_extension(ext)
130122

131123

132124
# Use a cache to prevent isa-l from being build twice. According to the

src/isal/_isal.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
# cython: language_level=3
22+
2123
from .version cimport ISAL_MAJOR_VERSION as C_ISAL_MAJOR_VERSION
2224
from .version cimport ISAL_MINOR_VERSION as C_ISAL_MINOR_VERSION
2325
from .version cimport ISAL_PATCH_VERSION as C_ISAL_PATCH_VERSION

src/isal/crc.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
# cython: language_level=3
22+
2123
cdef extern from "<isa-l/crc.h>":
2224
cdef unsigned int crc32_gzip_refl(
2325
unsigned int init_crc, #!< initial CRC value, 32 bits

src/isal/igzip_lib.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
# cython: language_level=3
22+
2123
cdef extern from "<isa-l/igzip_lib.h>":
2224
# Deflate compression standard defines
2325
int ISAL_DEF_MAX_HDR_SIZE

src/isal/igzip_lib.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
# cython: language_level=3
22+
# cython: binding=True
23+
2124
"""
2225
Pythonic interface to ISA-L's igzip_lib.
2326

src/isal/isal_zlib.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
# cython: language_level=3
22+
# cython: binding=True
23+
2124
"""
2225
Implementation of the zlib module using the ISA-L libraries.
2326
"""

0 commit comments

Comments
 (0)