Commit ff6b2b54 authored by Joseph Weston's avatar Joseph Weston
Browse files

enable coverage reports for cython modules

parent 242518ab
Pipeline #614 passed with stage
in 2 minutes and 26 seconds
[run]
plugins = Cython.Coverage
omit = */tests/*
job:
script:
- python3 setup.py build
- python3 setup.py build_ext -i
- python3 setup.py build --cython-trace
- python3 setup.py build_ext --cython-trace -i
- make -C doc clean && make -C doc html
- py.test --cov=kwant --flakes kwant
......@@ -48,6 +48,7 @@ README_END_BEFORE = 'See also in this directory:'
STATIC_VERSION_PATH = ('kwant', '_kwant_version.py')
REQUIRED_CYTHON_VERSION = (0, 22)
CYTHON_OPTION = '--cython'
CYTHON_TRACE_OPTION = '--cython-trace'
TUT_DIR = 'tutorial'
TUT_GLOB = 'doc/source/tutorial/*.py'
TUT_HIDDEN_PREFIX = '#HIDDEN'
......@@ -80,6 +81,16 @@ try:
except ValueError:
use_cython = version_is_from_git
try:
sys.argv.remove(CYTHON_TRACE_OPTION)
trace_cython = True
if not use_cython:
print('error: --cython-trace provided, but cython will not be run',
file=sys.stderr)
exit(1)
except ValueError:
trace_cython = False
if use_cython:
try:
import Cython
......@@ -312,6 +323,13 @@ def extensions():
'kwant/graph/c_slicer/partitioner.h',
'kwant/graph/c_slicer/slicer.h']})]
#### Add cython tracing macro
if trace_cython:
for args, kwargs in result:
macros = kwargs.get('define_macros', [])
macros.append(('CYTHON_TRACE', '1'))
kwargs['define_macros'] = macros
#### Add components of Kwant with external compile-time dependencies.
config = configparser.ConfigParser()
try:
......@@ -383,7 +401,9 @@ def ext_modules(extensions):
"""
if use_cython and cython_version >= REQUIRED_CYTHON_VERSION:
return cythonize([Extension(*args, **kwrds)
for args, kwrds in extensions], language_level=3)
for args, kwrds in extensions], language_level=3,
compiler_directives={'linetrace': trace_cython}
)
# Cython is not going to be run: replace pyx extension by that of
# the shipped translated file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment