Skip to content

Commit 72231f4

Browse files
committed
Set language directives globally
1 parent 0dda934 commit 72231f4

File tree

6 files changed

+19
-26
lines changed

6 files changed

+19
-26
lines changed

setup.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
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+
3944
class IsalExtension(Extension):
4045
"""Custom extension to allow for targeted modification."""
4146
pass
@@ -106,21 +111,21 @@ def build_extension(self, ext):
106111
# -fPIC needed for proper static linking
107112
ext.extra_compile_args = ["-fPIC"]
108113

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(ext, compiler_directives=compiler_directives)
123+
124+
for cython_ext in cythonized_exts:
125+
if line_tracing_enabled:
118126
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)
127+
cython_ext._needs_stub = False
128+
super().build_extension(cython_ext)
124129

125130

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

src/isal/_isal.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
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-
2321
from .version cimport ISAL_MAJOR_VERSION as C_ISAL_MAJOR_VERSION
2422
from .version cimport ISAL_MINOR_VERSION as C_ISAL_MINOR_VERSION
2523
from .version cimport ISAL_PATCH_VERSION as C_ISAL_PATCH_VERSION

src/isal/crc.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
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-
2321
cdef extern from "<isa-l/crc.h>":
2422
cdef unsigned int crc32_gzip_refl(
2523
unsigned int init_crc, #!< initial CRC value, 32 bits

src/isal/igzip_lib.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
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-
2321
cdef extern from "<isa-l/igzip_lib.h>":
2422
# Deflate compression standard defines
2523
int ISAL_DEF_MAX_HDR_SIZE

src/isal/igzip_lib.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
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-
2421
"""
2522
Pythonic interface to ISA-L's igzip_lib.
2623

src/isal/isal_zlib.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
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-
2421
"""
2522
Implementation of the zlib module using the ISA-L libraries.
2623
"""

0 commit comments

Comments
 (0)