From 68a94c8f072f14764130215fa0da45d5965471b2 Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Wed, 9 Mar 2016 11:45:07 -0800 Subject: [PATCH] Don't set linetrace unless testing coverage --- setup.py | 7 ++++++- tools/run_tests/build_python.sh | 6 +++++- tools/run_tests/run_python.sh | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index e1abe7fd8ff..b21265c5756 100644 --- a/setup.py +++ b/setup.py @@ -108,8 +108,13 @@ if "linux" in sys.platform or "darwin" in sys.platform: def cython_extensions(package_names, module_names, extra_sources, include_dirs, libraries, define_macros, build_with_cython=False): + # Set compiler directives linetrace argument only if we care about tracing; + # this is due to Cython having different behavior between linetrace being + # False and linetrace being unset. See issue #5689. + cython_compiler_directives = {} if ENABLE_CYTHON_TRACING: define_macros = define_macros + [('CYTHON_TRACE_NOGIL', 1)] + cython_compiler_directives['linetrace'] = True file_extension = 'pyx' if build_with_cython else 'c' module_files = [os.path.join(PYTHON_STEM, name.replace('.', '/') + '.' + file_extension) @@ -129,7 +134,7 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs, return Cython.Build.cythonize( extensions, include_path=include_dirs, - compiler_directives={'linetrace': bool(ENABLE_CYTHON_TRACING)}) + compiler_directives=cython_compiler_directives) else: return extensions diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh index f120fc7ed69..79a148faf1b 100755 --- a/tools/run_tests/build_python.sh +++ b/tools/run_tests/build_python.sh @@ -40,7 +40,11 @@ export PATH=$ROOT/bins/$CONFIG:$ROOT/bins/$CONFIG/protobuf:$PATH export CFLAGS="-I$ROOT/include -std=gnu99" export LDFLAGS="-L$ROOT/libs/$CONFIG" export GRPC_PYTHON_BUILD_WITH_CYTHON=1 -export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 + +if [ "$CONFIG" = "gcov" ] +then + export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 +fi tox --notest diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh index ace49e15142..d4b7250cbb7 100755 --- a/tools/run_tests/run_python.sh +++ b/tools/run_tests/run_python.sh @@ -40,10 +40,10 @@ export PATH=$ROOT/bins/$CONFIG:$ROOT/bins/$CONFIG/protobuf:$PATH export CFLAGS="-I$ROOT/include -std=c89" export LDFLAGS="-L$ROOT/libs/$CONFIG" export GRPC_PYTHON_BUILD_WITH_CYTHON=1 -export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 if [ "$CONFIG" = "gcov" ] then + export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 tox else $ROOT/.tox/py27/bin/python $ROOT/setup.py test_lite