summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxBo <max.bohnet@tuhh.de>2017-09-30 23:33:08 +0200
committerMaxBo <max.bohnet@tuhh.de>2017-09-30 23:39:34 +0200
commit77f27e990bbd6a9fe564813d5eab23e725b2f446 (patch)
tree97ebdfa67137ff1b6addcf89ae65daf7f93f22ae
parentca0e728483db495350350a2709d27e5c7edaee2c (diff)
downloadcython-77f27e990bbd6a9fe564813d5eab23e725b2f446.tar.gz
add regex to ######## coverage_test.py ########
remove deprecieated import in Coverage.py
-rw-r--r--Cython/Coverage.py1
-rw-r--r--tests/run/coverage_api.srctree31
2 files changed, 12 insertions, 20 deletions
diff --git a/Cython/Coverage.py b/Cython/Coverage.py
index 9c6b03d32..a180a2f16 100644
--- a/Cython/Coverage.py
+++ b/Cython/Coverage.py
@@ -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+
diff --git a/tests/run/coverage_api.srctree b/tests/run/coverage_api.srctree
index 4f5f9fcdf..405894280 100644
--- a/tests/run/coverage_api.srctree
+++ b/tests/run/coverage_api.srctree
@@ -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):