Skip to content

Commit

Permalink
maint: add coverage testing script
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarbenjamin committed Dec 12, 2022
1 parent 029ec02 commit 1094125
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
plugins = Cython.Coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ MANIFEST
.eggs
.local
*.egg-info
.coverage
4 changes: 4 additions & 0 deletions bin/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export C_INCLUDE_PATH=$(pwd)/.local/include
export LIBRARY_PATH=$(pwd)/.local/lib
export LD_LIBRARY_PATH=$(pwd)/.local/lib
export PYTHONPATH=$(pwd)/src
38 changes: 38 additions & 0 deletions bin/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# Note: cython's Cython/Coverage.py fails for pyx files that are included in
# other pyx files. This gives the following error:
#
# $ coverage report -m
# Plugin 'Cython.Coverage.Plugin' did not provide a file reporter for
# '.../python-flint/src/flint/fmpz.pyx'.
#
# A patch to the file is needed:
#
# --- Coverage.py.backup 2022-12-09 17:36:35.387690467 +0000
# +++ Coverage.py 2022-12-09 17:08:06.282516837 +0000
# @@ -172,7 +172,9 @@ class Plugin(CoveragePlugin):
# else:
# c_file, _ = self._find_source_files(filename)
# if not c_file:
# - return None
# + c_file = os.path.join(os.path.dirname(filename), 'pyflint.c')
# + if not os.path.exists(c_file):
# + return None
# rel_file_path, code = self._read_source_lines(c_file, filename)
# if code is None:
# return None # no source found
#
#

set -o errexit

source bin/activate

python setup.py build_ext --inplace


coverage run test/test.py

coverage report -m
coverage html
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
from numpy.distutils.system_info import default_include_dirs, default_lib_dirs

from distutils.sysconfig import get_config_vars
Expand Down Expand Up @@ -45,7 +46,9 @@
"flint._flint", ["src/flint/pyflint.pyx"],
libraries=libraries,
library_dirs=default_lib_dirs,
include_dirs=default_include_dirs)
include_dirs=default_include_dirs,
define_macros=[('CYTHON_TRACE', 1)],
)
]

for e in ext_modules:
Expand All @@ -54,7 +57,7 @@
setup(
name='python-flint',
cmdclass={'build_ext': build_ext},
ext_modules=ext_modules,
ext_modules=cythonize(ext_modules, compiler_directives={'linetrace': True, 'language_level':2}),
packages=['flint'],
package_dir={'': 'src'},
description='Bindings for FLINT and Arb',
Expand Down

0 comments on commit 1094125

Please sign in to comment.