From 3f9ad556e7deeeac4113b884408913dea015bc59 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Tue, 13 Mar 2012 12:33:45 -0700 Subject: [PATCH 1/3] FEAT: new shot at bento build. --- bento.info | 93 +++++++++++++++++++++++++++++++++++++++++ bscript | 29 +++++++++++++ cython.py | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 bento.info create mode 100644 bscript create mode 100644 cython.py diff --git a/bento.info b/bento.info new file mode 100644 index 00000000..4f9a2cbe --- /dev/null +++ b/bento.info @@ -0,0 +1,93 @@ +Name: scikits-image +Version: 0.6.0.dev0 +Summary: Image processing routines for SciPy +Url: http://scikits-image.org +DownloadUrl: http://github.com/scikits-image/scikits-image +Description: Image Processing SciKit + + Image processing algorithms for SciPy, including IO, morphology, filtering, + warping, color manipulation, object detection, etc. + + Please refer to the online documentation at + http://scikits-image.org/ +Maintainer: Stefan van der Walt +MaintainerEmail: stefan@sun.ac.za +License: Modified BSD +Classifiers: + Development Status :: 4 - Beta, + Environment :: Console, + Intended Audience :: Developers, + Intended Audience :: Science/Research, + License :: OSI Approved :: BSD License, + Programming Language :: C, + Programming Language :: Python, + Programming Language :: Python :: 3, + Topic :: Scientific/Engineering, + Operating System :: Microsoft :: Windows, + Operating System :: POSIX, + Operating System :: Unix, + Operating System :: MacOS + +HookFile: bscript + +Library: + Packages: + skimage, skimage.color, skimage.data, skimage.draw, skimage.exposure, + skimage.feature, skimage.filter, skimage.graph, skimage.io, + skimage.io._plugins, skimage.measure, skimage.morphology, + skimage.scripts, skimage.segmentation, skimage.transform, skimage.util + Extension: skimage.morphology._pnpoly + Sources: + skimage/morphology/_pnpoly.pyx + Extension: skimage.feature._greycomatrix + Sources: + skimage/feature/_greycomatrix.pyx + Extension: skimage.io._plugins._colormixer + Sources: + skimage/io/_plugins/_colormixer.pyx + Extension: skimage.measure._find_contours + Sources: + skimage/measure/_find_contours.pyx + Extension: skimage.graph._mcp + Sources: + skimage/graph/_mcp.pyx + Extension: skimage.io._plugins._histograms + Sources: + skimage/io/_plugins/_histograms.pyx + Extension: skimage.transform._hough_transform + Sources: + skimage/transform/_hough_transform.pyx + Extension: skimage.filter._ctmf + Sources: + skimage/filter/_ctmf.pyx + Extension: skimage.morphology.pyxcomp + Sources: + skimage/morphology/ccomp.pyx + Extension: skimage.morphology._watershed + Sources: + skimage/morphology/_watershed.pyx + 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 + Extension: skimage.morphology.pyxmorph + Sources: + skimage/morphology/cmorph.pyx + Extension: skimage.graph.heap + Sources: + skimage/graph/heap.pyx + +Executable: skivi + Module: skimage.scripts.skivi + Function: main diff --git a/bscript b/bscript new file mode 100644 index 00000000..0344abe9 --- /dev/null +++ b/bscript @@ -0,0 +1,29 @@ +import os.path as op + +from numpy.distutils.misc_util \ + import \ + get_numpy_include_dirs + +from bento.commands import hooks + +from bento.commands.extras.waf \ + import \ + ConfigureWafContext, BuildWafContext, register_options + +@hooks.startup +def startup(context): + context.register_context("configure", ConfigureWafContext) + context.register_context("build", BuildWafContext) + +@hooks.options +def options(context): + register_options(context) + +@hooks.pre_configure +def pre_configure(context): + conf = context.waf_context + conf.load("cython", tooldir=".") + + conf.env.INCLUDES = [] + conf.env.INCLUDES.extend(get_numpy_include_dirs()) + conf.env.INCLUDES.append(op.join("skimage", "morphology")) diff --git a/cython.py b/cython.py new file mode 100644 index 00000000..02795124 --- /dev/null +++ b/cython.py @@ -0,0 +1,119 @@ +#! /usr/bin/env python +# encoding: utf-8 +# Thomas Nagy, 2010 + +import re + +import waflib.Logs as _msg +from waflib import Task +from waflib.TaskGen import extension + +cy_api_pat = re.compile(r'\s*?cdef\s*?(public|api)\w*') +re_cyt = re.compile('import\\s(\\w+)\\s*$', re.M) + +@extension('.pyx') +def add_cython_file(self, node): + """ + Process a *.pyx* file given in the list of source files. No additional + feature is required:: + + def build(bld): + bld(features='c cshlib pyext', source='main.c foo.pyx', target='app') + """ + ext = '.c' + if 'cxx' in self.features: + self.env.append_unique('CYTHONFLAGS', '--cplus') + ext = '.cc' + tsk = self.create_task('cython', node, node.change_ext(ext)) + self.source += tsk.outputs + +class cython(Task.Task): + run_str = '${CYTHON} ${CYTHONFLAGS} -o ${TGT[0].abspath()} ${SRC}' + color = 'GREEN' + + vars = ['INCLUDES'] + """ + Rebuild whenever the INCLUDES change. The variables such as CYTHONFLAGS will be appended + by the metaclass. + """ + + ext_out = ['.h'] + """ + The creation of a .h file is known only after the build has begun, so it is not + possible to compute a build order just by looking at the task inputs/outputs. + """ + + def runnable_status(self): + """ + Perform a double-check to add the headers created by cython + to the output nodes. The scanner is executed only when the cython task + must be executed (optimization). + """ + ret = super(cython, self).runnable_status() + if ret == Task.ASK_LATER: + return ret + for x in self.generator.bld.raw_deps[self.uid()]: + if x.startswith('header:'): + self.outputs.append(self.inputs[0].parent.find_or_declare(x.replace('header:', ''))) + return super(cython, self).runnable_status() + + def scan(self): + """ + Return the dependent files (.pxd) by looking in the include folders. + Put the headers to generate in the custom list "bld.raw_deps". + To inspect the scanne results use:: + + $ waf clean build --zones=deps + """ + txt = self.inputs[0].read() + + mods = [] + for m in re_cyt.finditer(txt): + mods.append(m.group(1)) + + _msg.debug("cython: mods %r" % mods) + incs = getattr(self.generator, 'cython_includes', []) + incs = [self.generator.path.find_dir(x) for x in incs] + incs.append(self.inputs[0].parent) + + found = [] + missing = [] + for x in mods: + for y in incs: + k = y.find_resource(x + '.pxd') + if k: + found.append(k) + break + else: + missing.append(x) + _msg.debug("cython: found %r" % found) + + # Now the .h created - store them in bld.raw_deps for later use + has_api = False + has_public = False + for l in txt.splitlines(): + if cy_api_pat.match(l): + if ' api ' in l: + has_api = True + if ' public ' in l: + has_public = True + name = self.inputs[0].name.replace('.pyx', '') + if has_api: + missing.append('header:%s_api.h' % name) + if has_public: + missing.append('header:%s.h' % name) + + return (found, missing) + +def options(ctx): + ctx.add_option('--cython-flags', action='store', default='', help='space separated list of flags to pass to cython') + +def configure(ctx): + if not ctx.env.CC and not ctx.env.CXX: + ctx.fatal('Load a C/C++ compiler first') + if not ctx.env.PYTHON: + ctx.fatal('Load the python tool first!') + ctx.find_program('cython', var='CYTHON') + if getattr(ctx.options, "cython_flags", None): + ctx.env.CYTHONFLAGS = ctx.options.cython_flags + From 8743a139787a603528d76d807a53ec673aa1e8a0 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Thu, 5 Apr 2012 18:33:24 +0200 Subject: [PATCH 2/3] FEAT: update to bento master - simplify waf declaration. --- bento.info | 1 + bscript | 18 +------- cython.py | 119 ----------------------------------------------------- 3 files changed, 2 insertions(+), 136 deletions(-) delete mode 100644 cython.py diff --git a/bento.info b/bento.info index 4f9a2cbe..304e18bd 100644 --- a/bento.info +++ b/bento.info @@ -29,6 +29,7 @@ Classifiers: Operating System :: MacOS HookFile: bscript +UseBackends: Waf Library: Packages: diff --git a/bscript b/bscript index 0344abe9..71f1bd4a 100644 --- a/bscript +++ b/bscript @@ -6,24 +6,8 @@ from numpy.distutils.misc_util \ from bento.commands import hooks -from bento.commands.extras.waf \ - import \ - ConfigureWafContext, BuildWafContext, register_options - -@hooks.startup -def startup(context): - context.register_context("configure", ConfigureWafContext) - context.register_context("build", BuildWafContext) - -@hooks.options -def options(context): - register_options(context) - @hooks.pre_configure def pre_configure(context): conf = context.waf_context - conf.load("cython", tooldir=".") - conf.env.INCLUDES = [] - conf.env.INCLUDES.extend(get_numpy_include_dirs()) - conf.env.INCLUDES.append(op.join("skimage", "morphology")) + conf.env.INCLUDES.extend(get_numpy_include_dirs() + [op.join("skimage", "morphology")]) diff --git a/cython.py b/cython.py deleted file mode 100644 index 02795124..00000000 --- a/cython.py +++ /dev/null @@ -1,119 +0,0 @@ -#! /usr/bin/env python -# encoding: utf-8 -# Thomas Nagy, 2010 - -import re - -import waflib.Logs as _msg -from waflib import Task -from waflib.TaskGen import extension - -cy_api_pat = re.compile(r'\s*?cdef\s*?(public|api)\w*') -re_cyt = re.compile('import\\s(\\w+)\\s*$', re.M) - -@extension('.pyx') -def add_cython_file(self, node): - """ - Process a *.pyx* file given in the list of source files. No additional - feature is required:: - - def build(bld): - bld(features='c cshlib pyext', source='main.c foo.pyx', target='app') - """ - ext = '.c' - if 'cxx' in self.features: - self.env.append_unique('CYTHONFLAGS', '--cplus') - ext = '.cc' - tsk = self.create_task('cython', node, node.change_ext(ext)) - self.source += tsk.outputs - -class cython(Task.Task): - run_str = '${CYTHON} ${CYTHONFLAGS} -o ${TGT[0].abspath()} ${SRC}' - color = 'GREEN' - - vars = ['INCLUDES'] - """ - Rebuild whenever the INCLUDES change. The variables such as CYTHONFLAGS will be appended - by the metaclass. - """ - - ext_out = ['.h'] - """ - The creation of a .h file is known only after the build has begun, so it is not - possible to compute a build order just by looking at the task inputs/outputs. - """ - - def runnable_status(self): - """ - Perform a double-check to add the headers created by cython - to the output nodes. The scanner is executed only when the cython task - must be executed (optimization). - """ - ret = super(cython, self).runnable_status() - if ret == Task.ASK_LATER: - return ret - for x in self.generator.bld.raw_deps[self.uid()]: - if x.startswith('header:'): - self.outputs.append(self.inputs[0].parent.find_or_declare(x.replace('header:', ''))) - return super(cython, self).runnable_status() - - def scan(self): - """ - Return the dependent files (.pxd) by looking in the include folders. - Put the headers to generate in the custom list "bld.raw_deps". - To inspect the scanne results use:: - - $ waf clean build --zones=deps - """ - txt = self.inputs[0].read() - - mods = [] - for m in re_cyt.finditer(txt): - mods.append(m.group(1)) - - _msg.debug("cython: mods %r" % mods) - incs = getattr(self.generator, 'cython_includes', []) - incs = [self.generator.path.find_dir(x) for x in incs] - incs.append(self.inputs[0].parent) - - found = [] - missing = [] - for x in mods: - for y in incs: - k = y.find_resource(x + '.pxd') - if k: - found.append(k) - break - else: - missing.append(x) - _msg.debug("cython: found %r" % found) - - # Now the .h created - store them in bld.raw_deps for later use - has_api = False - has_public = False - for l in txt.splitlines(): - if cy_api_pat.match(l): - if ' api ' in l: - has_api = True - if ' public ' in l: - has_public = True - name = self.inputs[0].name.replace('.pyx', '') - if has_api: - missing.append('header:%s_api.h' % name) - if has_public: - missing.append('header:%s.h' % name) - - return (found, missing) - -def options(ctx): - ctx.add_option('--cython-flags', action='store', default='', help='space separated list of flags to pass to cython') - -def configure(ctx): - if not ctx.env.CC and not ctx.env.CXX: - ctx.fatal('Load a C/C++ compiler first') - if not ctx.env.PYTHON: - ctx.fatal('Load the python tool first!') - ctx.find_program('cython', var='CYTHON') - if getattr(ctx.options, "cython_flags", None): - ctx.env.CYTHONFLAGS = ctx.options.cython_flags - From cf0a473982fa83024803439ffda8ffda8df67dc0 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Wed, 25 Apr 2012 19:29:16 +0100 Subject: [PATCH 3/3] REF: tweak bento build. --- bscript | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bscript b/bscript index 71f1bd4a..44b3f3d6 100644 --- a/bscript +++ b/bscript @@ -6,8 +6,7 @@ from numpy.distutils.misc_util \ from bento.commands import hooks -@hooks.pre_configure -def pre_configure(context): +@hooks.post_configure +def post_configure(context): conf = context.waf_context - conf.env.INCLUDES = [] - conf.env.INCLUDES.extend(get_numpy_include_dirs() + [op.join("skimage", "morphology")]) + conf.env.INCLUDES = get_numpy_include_dirs() + [op.join("skimage", "morphology")]