diff --git a/.coveragerc b/.coveragerc index b1c22d95e71..e4450a53647 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,7 @@ [run] branch = True source = MDAnalysis +plugins = Cython.Coverage omit = */migration/* */MDAnalysis/tests/* diff --git a/.travis.yml b/.travis.yml index 3aeb35f9a61..d3f93b97953 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ env: - PYTEST_LIST="testsuite/MDAnalysisTests" - MAIN_CMD="pytest ${PYTEST_LIST}" - SETUP_CMD="${PYTEST_FLAGS}" - - BUILD_CMD="pip install -v package/ && (cd testsuite/ && python setup.py build)" + - BUILD_CMD="pip install -e package/ && (cd testsuite/ && python setup.py build)" - CONDA_MIN_DEPENDENCIES="mmtf-python mock six biopython networkx cython joblib matplotlib scipy griddataformats hypothesis gsd codecov" - CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn" - CONDA_CHANNELS='biobuilds conda-forge' @@ -34,6 +34,7 @@ env: - PIP_DEPENDENCIES="duecredit" - NUMPY_VERSION=stable - INSTALL_HOLE="true" + - CYTHON_TRACE_NOGIL=1 matrix: # Run a coverage test for most versions diff --git a/package/.coveragerc b/package/.coveragerc new file mode 100644 index 00000000000..37388f00129 --- /dev/null +++ b/package/.coveragerc @@ -0,0 +1,2 @@ +[run] +plugins = Cython.Coverage \ No newline at end of file diff --git a/package/setup.py b/package/setup.py index fc19059ff9b..b1291d138db 100755 --- a/package/setup.py +++ b/package/setup.py @@ -94,6 +94,7 @@ "parallelization module".format( Cython.__version__, required_version)) cython_found = False + cython_linetrace = bool(os.environ.get('CYTHON_TRACE_NOGIL', False)) except ImportError: cython_found = False if not is_release: @@ -320,6 +321,10 @@ def extensions(config): else: mathlib = ['m'] + if cython_linetrace: + extra_compile_args.append("-DCYTHON_TRACE_NOGIL") + cpp_extra_compile_args.append("-DCYTHON_TRACE_NOGIL") + libdcd = MDAExtension('MDAnalysis.lib.formats.libdcd', ['MDAnalysis/lib/formats/libdcd' + source_suffix], include_dirs=include_dirs + ['MDAnalysis/lib/formats/include'], @@ -416,7 +421,13 @@ def extensions(config): cython_generated = [] if use_cython: - extensions = cythonize(pre_exts) + extensions = cythonize( + pre_exts, + compiler_directives={'linetrace' : cython_linetrace, + 'embedsignature' : False}, + ) + if cython_linetrace: + print("Cython coverage will be enabled") for pre_ext, post_ext in zip(pre_exts, extensions): for source in post_ext.sources: if source not in pre_ext.sources: @@ -608,7 +619,7 @@ def dynamic_author_list(): ) # Releases keep their cythonized stuff for shipping. - if not config.get('keep_cythonized', default=is_release): + if not config.get('keep_cythonized', default=is_release) and not cython_linetrace: for cythonized in cythonfiles: try: os.unlink(cythonized)