Merge pull request #374 from tonysyu/add-rank-to-bentoinfo

Add rank extensions to bento.info
This commit is contained in:
Johannes Schönberger
2012-11-15 00:42:53 -08:00
2 changed files with 54 additions and 25 deletions
+30
View File
@@ -118,6 +118,36 @@ Library:
Extension: skimage._shared.geometry
Sources:
skimage/_shared/geometry.pyx
Extension: skimage.filter.rank._core16
Sources:
skimage/filter/rank/_core16.pyx
Extension: skimage.filter.rank._crank8
Sources:
skimage/filter/rank/_crank8.pyx
Extension: skimage.filter.rank._crank16
Sources:
skimage/filter/rank/_crank16.pyx
Extension: skimage.filter.rank._core8
Sources:
skimage/filter/rank/_core8.pyx
Extension: skimage.filter.rank.rank
Sources:
skimage/filter/rank/rank.pyx
Extension: skimage.filter.rank.bilateral_rank
Sources:
skimage/filter/rank/bilateral_rank.pyx
Extension: skimage.filter.rank._crank16_percentiles
Sources:
skimage/filter/rank/_crank16_percentiles.pyx
Extension: skimage.filter.rank.percentile_rank
Sources:
skimage/filter/rank/percentile_rank.pyx
Extension: skimage.filter.rank._crank8_percentiles
Sources:
skimage/filter/rank/_crank8_percentiles.pyx
Extension: skimage.filter.rank._crank16_bilateral
Sources:
skimage/filter/rank/_crank16_bilateral.pyx
Executable: skivi
Module: skimage.scripts.skivi
+24 -25
View File
@@ -5,7 +5,7 @@ import os
import re
RE_CYTHON = re.compile("config.add_extension\(['\"]([\S]+)['\"]")
RE_CYTHON = re.compile("config.add_extension\(\s*['\"]([\S]+)['\"]")
BENTO_TEMPLATE = """
Extension: {module_path}
@@ -23,7 +23,7 @@ def each_setup_in_pkg(top_dir):
def each_cy_in_setup(top_dir):
"""Yield path and name for each cython extension package's setup file."""
"""Yield path for each cython extension package's setup file."""
for dir_path, f in each_setup_in_pkg(top_dir):
text = f.read()
match = RE_CYTHON.findall(text)
@@ -38,30 +38,27 @@ def each_cy_in_setup(top_dir):
else:
path = dir_path
full_path = os.path.join(path, cy_file)
yield full_path, cy_file
yield full_path
def each_cy_in_bento(bento_file='bento.info'):
"""Yield path and name for each cython extension in bento info file."""
"""Yield path for each cython extension in bento info file."""
with open(bento_file) as f:
for line in f:
line = line.strip()
if line.startswith('Extension:'):
parts = line.split('.')
ext_name = parts[-1]
path = line.lstrip('Extension:').strip()
yield path, ext_name
yield path
def remove_common_extensions(cy_bento, cy_setup):
for ext_name in cy_bento.keys():
if ext_name in cy_setup:
spath = cy_setup.pop(ext_name)
bpath = cy_bento.pop(ext_name)
if not spath.replace(os.path.sep, '.') == bpath:
print "Mismatched paths:"
print " setup.py: ", spath
print " bento.info:", bpath
# normalize so that cy_setup and cy_bento have the same separator
cy_setup = set(ext.replace('/', '.') for ext in cy_setup)
cy_setup_diff = cy_setup.difference(cy_bento)
cy_setup_diff = set(ext.replace('.', '/') for ext in cy_setup_diff)
cy_bento_diff = cy_bento.difference(cy_setup)
return cy_bento_diff, cy_setup_diff
def print_results(cy_bento, cy_setup):
def info(text):
@@ -69,28 +66,30 @@ def print_results(cy_bento, cy_setup):
print(text)
print('-' * len(text))
print "Bento errors:"
print "-------------"
if not (cy_bento or cy_setup):
print "bento.info and setup.py files match."
if cy_bento:
info("The following extensions in 'bento.info' were not found:")
print('\n'.join(cy_bento.keys()))
info("Extensions found in 'bento.info' but not in any 'setup.py:")
print('\n'.join(cy_bento))
if cy_setup:
info("The following cython files exist but were not in 'bento.info':")
info("Extensions found in a 'setup.py' but not in any 'bento.info:")
print('\n'.join(cy_setup))
info("Consider adding the following to the 'bento.info' Library:")
for ext_name, dir_path in cy_setup.iteritems():
print BENTO_TEMPLATE.format(module_path=dir_path.replace('/', '.'),
for dir_path in cy_setup:
module_path = dir_path.replace('/', '.')
print BENTO_TEMPLATE.format(module_path=module_path,
dir_path=dir_path)
if __name__ == '__main__':
# All cython extensions defined in 'setup.py' files.
cy_setup = dict((ext, path) for path, ext in each_cy_in_setup('skimage'))
cy_setup = set(each_cy_in_setup('skimage'))
# All cython extensions defined 'bento.info' file.
cy_bento = dict((ext, path) for path, ext in each_cy_in_bento())
cy_bento = set(each_cy_in_bento())
remove_common_extensions(cy_bento, cy_setup)
cy_bento, cy_setup = remove_common_extensions(cy_bento, cy_setup)
print_results(cy_bento, cy_setup)