Commit b6915e50 authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files

Enable cython linetrace while using tox

parent c5c1b22465cd
...@@ -61,8 +61,8 @@ More ...@@ -61,8 +61,8 @@ More
:target: https://pypi.python.org/pypi/fluidfft/ :target: https://pypi.python.org/pypi/fluidfft/
:alt: Latest version :alt: Latest version
.. |coverage| image:: https://codecov.io/bb/fluiddyn/fluidfft/branch/default/graph/badge.svg .. |coverage| image:: https://codecov.io/gh/fluiddyn/fluidfft/graph/badge.svg
:target: https://codecov.io/bb/fluiddyn/fluidfft/branch/default/ :target: https://codecov.io/gh/fluiddyn/fluidfft
:alt: Code coverage :alt: Code coverage
.. |travis| image:: https://travis-ci.org/fluiddyn/fluidfft.svg?branch=master .. |travis| image:: https://travis-ci.org/fluiddyn/fluidfft.svg?branch=master
......
...@@ -40,6 +40,7 @@ import subprocess ...@@ -40,6 +40,7 @@ import subprocess
from copy import copy from copy import copy
import importlib import importlib
import multiprocessing import multiprocessing
import warnings
from distutils.ccompiler import CCompiler from distutils.ccompiler import CCompiler
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
...@@ -72,6 +73,7 @@ if can_import_cython: ...@@ -72,6 +73,7 @@ if can_import_cython:
default_options as cython_default_options, \ default_options as cython_default_options, \
compile_single as cython_compile compile_single as cython_compile
try: try:
from concurrent.futures import ThreadPoolExecutor as Pool from concurrent.futures import ThreadPoolExecutor as Pool
PARALLEL_COMPILE = True PARALLEL_COMPILE = True
...@@ -206,7 +208,8 @@ class FunctionsRunner(CommandsRunner): ...@@ -206,7 +208,8 @@ class FunctionsRunner(CommandsRunner):
def make_function_cpp_from_pyx(cpp_file, pyx_file, def make_function_cpp_from_pyx(cpp_file, pyx_file,
include_dirs=None, include_dirs=None,
full_module_name=None, options=None): compiler_directives={},
full_module_name=None, options={}):
path_dir = os.path.split(cpp_file)[0] path_dir = os.path.split(cpp_file)[0]
if not os.path.exists(path_dir): if not os.path.exists(path_dir):
os.makedirs(path_dir) os.makedirs(path_dir)
...@@ -222,6 +225,7 @@ def make_function_cpp_from_pyx(cpp_file, pyx_file, ...@@ -222,6 +225,7 @@ def make_function_cpp_from_pyx(cpp_file, pyx_file,
include_path=include_dirs, include_path=include_dirs,
output_file=cpp_file, output_file=cpp_file,
cplus=True, cplus=True,
compiler_directives=compiler_directives,
compile_time_env={'MPI4PY': can_import_mpi4py}) compile_time_env={'MPI4PY': can_import_mpi4py})
# return (func, args, kwargs) # return (func, args, kwargs)
...@@ -369,6 +373,20 @@ def make_extensions(extensions, ...@@ -369,6 +373,20 @@ def make_extensions(extensions,
files['cpp'].append(source) files['cpp'].append(source)
files['o'] = [] files['o'] = []
# Enable linetrace for Cython extensions while using tox
if can_import_cython and os.getenv('TOXENV') is not None:
warnings.warn(
'Enabling linetrace for coverage tests. Extensions can be really '
'slow. Recompile for practical use.')
compiler_directives = {'linetrace': True}
cython_options = {'CFLAGS': ' -DCYTHON_TRACE_NOGIL=1'}
if 'CFLAGS' in options:
options['CFLAGS'] += cython_options['CFLAGS']
else:
options.update(cython_options)
else:
compiler_directives = {}
# cythonize .pyx files if needed # cythonize .pyx files if needed
commands = [] commands = []
for pyx_file in files['pyx']: for pyx_file in files['pyx']:
...@@ -383,6 +401,7 @@ def make_extensions(extensions, ...@@ -383,6 +401,7 @@ def make_extensions(extensions,
cpp_file, pyx_file, cpp_file, pyx_file,
full_module_name=full_module_name, full_module_name=full_module_name,
include_dirs=include_dirs, include_dirs=include_dirs,
compiler_directives=compiler_directives,
options=options) options=options)
if command is not None: if command is not None:
commands.append(command) commands.append(command)
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
ignore = E225,E226,E303,E201,E202, W503 ignore = E225,E226,E303,E201,E202, W503
[coverage:run] [coverage:run]
source = ./fluidfft source =
./fluidfft
./src_cy
data_file = .coverage/coverage data_file = .coverage/coverage
omit = */test*.py omit = */test*.py
plugins = Cython.Coverage
[coverage:report] [coverage:report]
show_missing = True show_missing = True
......
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