Skip to content

Commit e516588

Browse files
committed
Rework the gcov setup to only enable is gcov can be used (linux/gcc basically).
1 parent 3da6256 commit e516588

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

setup.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import io
77
import os
8+
import platform
89
import re
910
from glob import glob
1011
from os.path import basename
@@ -27,6 +28,17 @@ def read(*names, **kwargs):
2728
return fh.read()
2829

2930

31+
# Enable code coverage for C code: we can't use CFLAGS=-coverage in tox.ini, since that may mess with compiling
32+
# dependencies (e.g. numpy). Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
33+
# deps have been safely installed).
34+
if 'TOXENV' in os.environ and os.environ.get('SETUPPY_GCOV') == 'enabled' and platform.system() == 'Linux':
35+
CFLAGS = ['-fprofile-arcs', '-ftest-coverage']
36+
LFLAGS = ['-lgcov']
37+
else:
38+
CFLAGS = []
39+
LFLAGS = []
40+
41+
3042
class optional_build_ext(build_ext):
3143
"""Allow the building of C extensions to fail."""
3244
def run(self):
@@ -117,9 +129,9 @@ def _unavailable(self, e):
117129
Extension(
118130
splitext(relpath(path, 'src').replace(os.sep, '.'))[0],
119131
sources=[path],
120-
extra_compile_args=os.environ.get('SETUPPY_CFLAGS', '').split(),
121-
extra_link_args=os.environ.get('SETUPPY_LFLAGS', '').split(),
122-
include_dirs=[dirname(path)],
132+
extra_compile_args=CFLAGS,
133+
extra_link_args=LFLAGS,
134+
include_dirs=[dirname(path)]
123135
)
124136
for root, _, _ in os.walk('src')
125137
for path in glob(join(root, '*.c'))

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ basepython =
2323
setenv =
2424
PYTHONPATH={toxinidir}/tests
2525
PYTHONUNBUFFERED=yes
26-
cover: SETUPPY_CFLAGS=-fprofile-arcs -ftest-coverage
27-
cover: SETUPPY_LFLAGS=-lgcov
26+
cover: SETUPPY_GCOV=enabled
2827
passenv =
2928
*
3029
usedevelop =

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy