Skip to content

Commit 1094125

Browse files
committed
maint: add coverage testing script
1 parent 029ec02 commit 1094125

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

.coveragerc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
plugins = Cython.Coverage

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ MANIFEST
1212
.eggs
1313
.local
1414
*.egg-info
15+
.coverage

bin/activate

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export C_INCLUDE_PATH=$(pwd)/.local/include
2+
export LIBRARY_PATH=$(pwd)/.local/lib
3+
export LD_LIBRARY_PATH=$(pwd)/.local/lib
4+
export PYTHONPATH=$(pwd)/src

bin/coverage.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Note: cython's Cython/Coverage.py fails for pyx files that are included in
4+
# other pyx files. This gives the following error:
5+
#
6+
# $ coverage report -m
7+
# Plugin 'Cython.Coverage.Plugin' did not provide a file reporter for
8+
# '.../python-flint/src/flint/fmpz.pyx'.
9+
#
10+
# A patch to the file is needed:
11+
#
12+
# --- Coverage.py.backup 2022-12-09 17:36:35.387690467 +0000
13+
# +++ Coverage.py 2022-12-09 17:08:06.282516837 +0000
14+
# @@ -172,7 +172,9 @@ class Plugin(CoveragePlugin):
15+
# else:
16+
# c_file, _ = self._find_source_files(filename)
17+
# if not c_file:
18+
# - return None
19+
# + c_file = os.path.join(os.path.dirname(filename), 'pyflint.c')
20+
# + if not os.path.exists(c_file):
21+
# + return None
22+
# rel_file_path, code = self._read_source_lines(c_file, filename)
23+
# if code is None:
24+
# return None # no source found
25+
#
26+
#
27+
28+
set -o errexit
29+
30+
source bin/activate
31+
32+
python setup.py build_ext --inplace
33+
34+
35+
coverage run test/test.py
36+
37+
coverage report -m
38+
coverage html

setup.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from distutils.core import setup
66
from distutils.extension import Extension
77
from Cython.Distutils import build_ext
8+
from Cython.Build import cythonize
89
from numpy.distutils.system_info import default_include_dirs, default_lib_dirs
910

1011
from distutils.sysconfig import get_config_vars
@@ -45,7 +46,9 @@
4546
"flint._flint", ["src/flint/pyflint.pyx"],
4647
libraries=libraries,
4748
library_dirs=default_lib_dirs,
48-
include_dirs=default_include_dirs)
49+
include_dirs=default_include_dirs,
50+
define_macros=[('CYTHON_TRACE', 1)],
51+
)
4952
]
5053

5154
for e in ext_modules:
@@ -54,7 +57,7 @@
5457
setup(
5558
name='python-flint',
5659
cmdclass={'build_ext': build_ext},
57-
ext_modules=ext_modules,
60+
ext_modules=cythonize(ext_modules, compiler_directives={'linetrace': True, 'language_level':2}),
5861
packages=['flint'],
5962
package_dir={'': 'src'},
6063
description='Bindings for FLINT and Arb',

0 commit comments

Comments
 (0)