@@ -49,6 +49,10 @@ def with_patches():
49
49
if retcode != 0 :
50
50
raise RuntimeError (f"Failed to reset submodules: { command } " )
51
51
52
+ compiler_directives = {
53
+ "language_level" : "3" ,
54
+ 'embedsignature' : True ,
55
+ }
52
56
SOURCE_DIR = Path ("pybwa" )
53
57
BUILD_DIR = Path ("cython_build" )
54
58
compile_args = []
@@ -62,20 +66,34 @@ def with_patches():
62
66
define_macros = [("HAVE_PTHREAD" , None ), ("USE_MALLOC_WRAPPERS" , None )]
63
67
h_files = []
64
68
c_files = []
69
+
70
+ exclude_files = {
71
+ "pybwa" : ["libbwaaln.c" , "libbwaindex.c" , "libbwamem.c" ],
72
+ "bwa" : ['example.c' , 'main.c' ]
73
+ }
65
74
for root_dir in library_dirs :
66
75
h_files .extend (str (x ) for x in Path (root_dir ).rglob ("*.h" ))
67
- c_files .extend (str (x ) for x in Path (root_dir ).rglob ("*.c" ) if x .name not in ['example.c' , 'main.c' ])
76
+ c_files .extend (str (x ) for x in Path (root_dir ).rglob ("*.c" ) if x .name not in exclude_files [root_dir ])
77
+
78
+ # Check if we should build with linetracing for coverage
79
+ build_with_coverage = os .environ .get ("CYTHON_TRACE" , "false" ).lower () in ("1" , "true" , '"true"' )
80
+ if build_with_coverage :
81
+ compiler_directives ["linetrace" ] = True
82
+ compiler_directives ['emit_code_comments' ] = True
83
+ define_macros .extend ([('CYTHON_TRACE' , 1 ), ('CYTHON_TRACE_NOGIL' , 1 ), ('DCYTHON_USE_SYS_MONITORING' , 0 )])
84
+ BUILD_DIR = Path ("." ) # the compiled .c files need to be next to the .pyx files for coverage
68
85
69
86
if platform .system () != 'Windows' :
70
- compile_args = [
87
+ compile_args . extend ( [
71
88
"-Wno-unused-result" ,
72
89
"-Wno-unreachable-code" ,
73
90
"-Wno-single-bit-bitfield-constant-conversion" ,
74
91
"-Wno-deprecated-declarations" ,
75
92
"-Wno-unused" ,
76
93
"-Wno-strict-prototypes" ,
77
94
"-Wno-sign-compare" ,
78
- "-Wno-error=declaration-after-statement" ]
95
+ "-Wno-error=declaration-after-statement"
96
+ ])
79
97
80
98
libbwaindex_module = Extension (
81
99
name = 'pybwa.libbwaindex' ,
@@ -135,8 +153,8 @@ def cythonize_helper(extension_modules: List[Extension]) -> List[Extension]:
135
153
# Parallelize our build
136
154
nthreads = multiprocessing .cpu_count () * 2 ,
137
155
138
- # Tell Cython we're using Python 3. Becomes default in Cython 3
139
- compiler_directives = { "language_level" : "3" , 'embedsignature' : True } ,
156
+ # Compiler directives (e.g. language, or line tracing for coverage)
157
+ compiler_directives = compiler_directives ,
140
158
141
159
# (Optional) Always rebuild, even if files untouched
142
160
force = True ,
0 commit comments