Merge pull request #288 from tonysyu/bento-update

PKG: Bento update.
This commit is contained in:
Stefan van der Walt
2012-09-01 08:40:49 -07:00
2 changed files with 126 additions and 10 deletions
+31 -10
View File
@@ -1,5 +1,5 @@
Name: scikits-image
Version: 0.7.0.dev
Version: 0.7.0.dev0
Summary: Image processing routines for SciPy
Url: http://scikits-image.org
DownloadUrl: http://github.com/scikits-image/scikits-image
@@ -40,9 +40,6 @@ Library:
Extension: skimage.morphology._pnpoly
Sources:
skimage/morphology/_pnpoly.pyx
Extension: skimage.feature._greycomatrix
Sources:
skimage/feature/_greycomatrix.pyx
Extension: skimage.feature._template
Sources:
skimage/feature/_template.pyx
@@ -76,15 +73,9 @@ Library:
Extension: skimage.morphology._convex_hull
Sources:
skimage/morphology/_convex_hull.pyx
Extension: skimage.morphology._skeletonize
Sources:
skimage/morphology/_skeletonize.pyx
Extension: skimage.draw._draw
Sources:
skimage/draw/_draw.pyx
Extension: skimage.transform._project
Sources:
skimage/transform/_project.pyx
Extension: skimage.graph._spath
Sources:
skimage/graph/_spath.pyx
@@ -94,6 +85,36 @@ Library:
Extension: skimage.graph.heap
Sources:
skimage/graph/heap.pyx
Extension: skimage.morphology._greyreconstruct
Sources:
skimage/morphology/_greyreconstruct.pyx
Extension: skimage.feature._texture
Sources:
skimage/feature/_texture.pyx
Extension: skimage._shared.transform
Sources:
skimage/_shared/transform.pyx
Extension: skimage.segmentation._slic
Sources:
skimage/segmentation/_slic.pyx
Extension: skimage.segmentation._quickshift
Sources:
skimage/segmentation/_quickshift.pyx
Extension: skimage.morphology._skeletonize_cy
Sources:
skimage/morphology/_skeletonize_cy.pyx
Extension: skimage.transform._warps_cy
Sources:
skimage/transform/_warps_cy.pyx
Extension: skimage._shared.interpolation
Sources:
skimage/_shared/interpolation.pyx
Extension: skimage.segmentation._felzenszwalb_cy
Sources:
skimage/segmentation/_felzenszwalb_cy.pyx
Extension: skimage._shared.geometry
Sources:
skimage/_shared/geometry.pyx
Executable: skivi
Module: skimage.scripts.skivi
+95
View File
@@ -0,0 +1,95 @@
"""
Check that Cython extensions in setup.py files match those in bento.info.
"""
import os
import re
RE_CYTHON = re.compile("config.add_extension\(['\"]([\S]+)['\"]")
BENTO_TEMPLATE = """
Extension: {module_path}
Sources:
{dir_path}.pyx"""
def each_setup_in_pkg(top_dir):
"""Yield path and file object for each setup.py file"""
for dir_path, dir_names, filenames in os.walk(top_dir):
for fname in filenames:
if fname == 'setup.py':
with open(os.path.join(dir_path, 'setup.py')) as f:
yield dir_path, f
def each_cy_in_setup(top_dir):
"""Yield path and name 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)
if match:
for cy_file in match:
# if cython files in different directory than setup.py
if '.' in cy_file:
parts = cy_file.split('.')
cy_file = parts[-1]
# Don't overwrite dir_path for subsequent iterations.
path = os.path.join(dir_path, *parts[:-1])
else:
path = dir_path
full_path = os.path.join(path, cy_file)
yield full_path, cy_file
def each_cy_in_bento(bento_file='bento.info'):
"""Yield path and name 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
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
def print_results(cy_bento, cy_setup):
def info(text):
print
print(text)
print('-' * len(text))
print # blank line; just for aesthetics
if cy_bento:
info("The following extensions in 'bento.info' were not found:")
print('\n'.join(cy_bento.keys()))
if cy_setup:
info("The following cython files exist but were not in '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('/', '.'),
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'))
# All cython extensions defined 'bento.info' file.
cy_bento = dict((ext, path) for path, ext in each_cy_in_bento())
remove_common_extensions(cy_bento, cy_setup)
print_results(cy_bento, cy_setup)