Commit 77f27e99 authored by MaxBo's avatar MaxBo

add regex to ######## coverage_test.py ########

remove deprecieated import in Coverage.py
parent ca0e7284
......@@ -9,7 +9,6 @@ from __future__ import absolute_import
import re
import os.path
import sys
import glob
from collections import defaultdict
from coverage.plugin import CoveragePlugin, FileTracer, FileReporter # requires coverage.py 4.0+
......
......@@ -4,7 +4,6 @@
"""
PYTHON -c "import shutil; shutil.copy('pkg/coverage_test_pyx.pyx', 'pkg/coverage_test_pyx.pxi')"
PYTHON setup.py build_ext -i
PYTHON rename_pyd.py
PYTHON coverage_test.py
"""
......@@ -25,20 +24,6 @@ setup(ext_modules = cythonize([
plugins = Cython.Coverage
######## rename_pyd.py ########
import os
import glob
pyd_files = glob.glob('**/*.pyd', recursive=True)
for filepath in pyd_files:
folder, fn = os.path.split(filepath)
basename, ext = os.path.splitext(fn)
new_name = os.path.splitext(basename)[0] + '.pyd'
new_filepath = os.path.join(folder, new_name)
os.rename(filepath, new_filepath)
######## pkg/__init__.py ########
######## pkg/coverage_test_py.py ########
......@@ -159,10 +144,18 @@ for module in [coverage_test_py, coverage_test_pyx, coverage_test_include_pyx,
def source_file_for(module):
module_name = module.__name__
path, ext = os.path.splitext(module.__file__)
platform_suffix = re.search(r'[.](?:cpython|pypy)-[0-9]+[^.]*$', path, re.I)
if platform_suffix:
path = path[:platform_suffix.start()]
return path + '.' + module_name.rsplit('_', 1)[-1]
if ext == '.so':
# Linux/Unix/Mac extension module
platform_suffix = re.search(r'[.](?:cpython|pypy)-[0-9]+[-_a-z0-9]*$', path, re.I)
if platform_suffix:
path = path[:platform_suffix.start()]
elif ext == '.pyd':
# Windows extension module
platform_suffix = re.search(r'[.]cp[0-9]+-win[_a-z0-9]*$', path, re.I)
if platform_suffix:
path = path[:platform_suffix.start()]
source_filepath = path + '.' + module_name.rsplit('_', 1)[-1]
return source_filepath
def run_coverage(module):
......
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