Permalink
Browse files

REF: simplify hook scripts using new tweak_builder facility in bento.

  • Loading branch information...
1 parent c093474 commit 56971c57789e2355a7c7d2a9c443ff8505930ae3 @cournape cournape committed Apr 23, 2012
View
@@ -2,17 +2,8 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
-
- context.register_builder("_quadpack",
- lambda e: default_builder(e, use="quadpack linpack_lite mach FBLAS CLIB"))
- context.register_builder("_odepack",
- lambda e: default_builder(e, use="odepack linpack_lite mach FBLAS CLIB"))
- context.register_builder("vode",
- lambda e: default_builder(e,
- features="c cshlib pyext bento f2py",
- use="odepack linpack_lite mach FBLAS CLIB"))
- context.register_builder("_dop",
- lambda e: default_builder(e,
- features="c fc cshlib pyext bento f2py",
- use="dop FBLAS CLIB"))
+ context.tweak_builder("_quadpack", use="quadpack linpack_lite mach FBLAS CLIB")
+ context.tweak_builder("_odepack", use="odepack linpack_lite mach FBLAS CLIB")
+ context.tweak_builder("vode", features="c cshlib pyext bento f2py",
+ use="odepack linpack_lite mach FBLAS CLIB")
+ context.tweak_builder("_dop", features="c fc cshlib pyext bento f2py", use="dop FBLAS CLIB")
View
@@ -2,21 +2,7 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
-
- context.register_builder("_fitpack",
- lambda e: default_builder(e,
- use="fitpack FBLAS CLIB",
- features="c fc cshlib pyext bento f2py"))
- context.register_builder("interpnd",
- lambda e: default_builder(e,
- use="FBLAS CLIB",
- features="c fc cshlib pyext bento f2py"))
- context.register_builder("dfitpack",
- lambda e: default_builder(e,
- use="fitpack FBLAS CLIB",
- features="c fc cshlib pyext bento f2py"))
- context.register_builder("_interpolate",
- lambda e: default_builder(e,
- use="FBLAS CLIB",
- features="cxx cxxshlib fc pyext bento"))
+ context.tweak_builder("_fitpack", use="fitpack FBLAS CLIB", features="c fc cshlib pyext bento f2py")
+ context.tweak_builder("interpnd", use="FBLAS CLIB", features="c fc cshlib pyext bento f2py")
+ context.tweak_builder("dfitpack", use="fitpack FBLAS CLIB", features="c fc cshlib pyext bento f2py")
+ context.tweak_builder("_interpolate", use="FBLAS CLIB", features="cxx cxxshlib fc pyext bento")
View
@@ -6,7 +6,7 @@ from bento.commands import hooks
def pre_build(context):
default_builder = context.default_builder
- def builder(extension):
+ def fblas_builder(extension):
source = extension.sources[:]
if sys.platform == "darwin":
source.pop(source.index("fblaswrap.f.src"))
@@ -15,13 +15,13 @@ def pre_build(context):
features="c fc pyext bento cshlib f2py",
source=source,
use="FBLAS CLIB")
- context.register_builder("fblas", builder)
+ context.register_builder("fblas", fblas_builder)
- def builder(extension):
+ def cblas_builder(extension):
kw = {}
if context.waf_context.env.HAS_CBLAS:
kw["use"] = "CBLAS"
return default_builder(extension,
features="c fc pyext bento cshlib f2py",
**kw)
- context.register_builder("cblas", builder)
+ context.register_builder("cblas", cblas_builder)
View
@@ -1,30 +1,22 @@
-import sys
-
from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
default_builder = context.default_builder
- def builder(extension):
- return default_builder(extension,
- features="c fc pyext bento cshlib f2py",
- use="FLAPACK")
- context.register_builder("flapack", builder)
+ context.tweak_builder("flapack", features="c fc pyext bento cshlib f2py",
+ use="FLAPACK")
- def builder(extension):
+ def clapack_builder(extension):
kw = {"features": "c fc pyext bento cshlib f2py"}
if context.waf_context.env.HAS_CLAPACK:
kw["use"] = "CLAPACK"
else:
kw["source"] = ["dummy_clapack.pyf"]
return default_builder(extension, **kw)
- context.register_builder("clapack", builder)
-
- def builder(extension):
- return default_builder(extension,
- features="c fc pyext bento cshlib f2py f2py_fortran",
- use="FLAPACK CLIB")
- context.register_builder("calc_lwork", builder)
+ context.register_builder("clapack", clapack_builder)
+ context.tweak_builder("calc_lwork",
+ features="c fc pyext bento cshlib f2py f2py_fortran",
+ use="FLAPACK CLIB")
context.disable_extension("atlas_version")
View
@@ -8,7 +8,7 @@ def pre_build(context):
bld = context.waf_context
f2py = bld.tools["f2py"]
- def builder(extension):
+ def fblas_builder(extension):
source = extension.sources[:]
if sys.platform == "darwin":
source.pop(source.index("src/fblaswrap.f"))
@@ -17,23 +17,18 @@ def pre_build(context):
features="c fc pyext bento cshlib f2py",
source=source,
use="FBLAS CLIB")
- context.register_builder("fblas", builder)
+ context.register_builder("fblas", fblas_builder)
- def builder(extension):
+ def cblas_builder(extension):
t = default_builder(extension,
features="c fc pyext bento cshlib f2py",
use="CBLAS")
t.mappings[".pyf"] = f2py.interface_gen_callback
return t
- context.register_builder("cblas", builder)
+ context.register_builder("cblas", cblas_builder)
- def builder(extension):
- t = default_builder(extension,
- features="c fc pyext bento cshlib f2py",
- use="FLAPACK CLIB")
- #t.mappings[".pyf"] = f2py.interface_gen_callback
- return t
- context.register_builder("flapack", builder)
+ context.tweak_builder("flapack", features="c fc pyext bento cshlib f2py",
+ use="FLAPACK CLIB")
def builder(extension):
kw = {}
@@ -49,18 +44,14 @@ def pre_build(context):
return t
context.register_builder("clapack", builder)
- context.register_builder("_flinalg",
- lambda e: default_builder(e,
- features="c fc pyext bento cshlib f2py f2py_fortran",
- use="FLAPACK CLIB"))
- context.register_builder("calc_lwork",
- lambda e: default_builder(e,
- features="c fc pyext bento cshlib f2py f2py_fortran",
- use="FLAPACK CLIB"))
+ context.tweak_builder("_flinalg", features="c fc pyext bento cshlib f2py f2py_fortran",
+ use="FLAPACK CLIB")
+ context.tweak_builder("calc_lwork", features="c fc pyext bento cshlib f2py f2py_fortran",
+ use="FLAPACK CLIB")
defines = []
if bld.env.HAS_ATLAS:
raise NotImplementedError("Atlas not implemented yet")
else:
defines.append("NO_ATLAS_INFO=1")
- context.register_builder("atlas_version", lambda e: default_builder(e, defines=defines))
+ context.tweak_builder("atlas_version", defines=defines)
View
@@ -1,5 +1,3 @@
-HookFile: bscript
-
Library:
Extension: _nd_image
Sources: src/*.c
View
No changes.
View
@@ -2,8 +2,6 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- def builder(extension):
- return context.default_builder(extension,
- features="c fc pyext bento cshlib",
- use="odrpack FBLAS CLIB")
- context.register_builder("__odrpack", builder)
+ context.tweak_builder("__odrpack",
+ features="c fc pyext bento cshlib",
+ use="odrpack FBLAS CLIB")
View
@@ -2,22 +2,16 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
+ features="c fc pyext bento cshlib"
+ f2py_features = "c fc pyext bento cshlib f2py"
+ use = "minpack rootfind FLAPACK CLIB"
- def builder(extension):
- return default_builder(extension,
- features="c fc pyext bento cshlib",
- use="minpack rootfind FLAPACK CLIB")
- def builder_f2py(extension):
- return default_builder(extension,
- features="c fc pyext bento cshlib f2py",
- use="minpack rootfind FLAPACK CLIB")
- context.register_builder("_lbfgsb", builder_f2py)
- context.register_builder("_cobyla", builder_f2py)
- context.register_builder("minpack2", builder_f2py)
- context.register_builder("_nnls", builder_f2py)
- context.register_builder("_slsqp", builder_f2py)
+ context.tweak_builder("_lbfgsb", features=f2py_features, use=use)
+ context.tweak_builder("_cobyla", features=f2py_features, use=use)
+ context.tweak_builder("minpack2", features=f2py_features, use=use)
+ context.tweak_builder("_nnls", features=f2py_features, use=use)
+ context.tweak_builder("_slsqp", features=f2py_features, use=use)
- context.register_builder("_zeros", builder)
- context.register_builder("_minpack", builder)
- context.register_builder("moduleTNC", builder)
+ context.tweak_builder("_zeros", features=features, use=use)
+ context.tweak_builder("_minpack", features=features, use=use)
+ context.tweak_builder("moduleTNC", features=features, use=use)
View
@@ -2,5 +2,4 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
- context.register_builder("sigtools", lambda e: default_builder(e, includes="."))
+ context.tweak_builder("sigtools", includes=".")
@@ -2,13 +2,9 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- bld = context.waf_context
default_builder = context.default_builder
- def builder(extension):
- return default_builder(extension,
- use="superlu_src FLAPACK")
- context.register_builder("_superlu", builder)
+ context.tweak_builder("_superlu", use="superlu_src FLAPACK")
def st_builder(extension):
return default_builder(extension,
@@ -25,8 +25,5 @@ def pre_build(context):
use="cshlib")
context.register_compiled_library_builder("arpack", builder)
- def builder(extension):
- return default_builder(extension,
- features="c fc pyext cshlib f2py bento",
- use="arpack FLAPACK CLIB")
- context.register_builder("_arpack", builder)
+ context.tweak_builder("_arpack", features="c fc pyext cshlib f2py bento",
+ use="arpack FLAPACK CLIB")
@@ -2,12 +2,6 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- bld = context.waf_context
-
- def builder(extension):
- bld(features="cxx cxxshlib pyext bento",
- source=extension.sources,
- defines=('__STDC_FORMAT_MACROS',),
- target=extension.name)
for e in ["_csr", "_csc", "_coo", "_bsr", "_dia", "_csgraph"]:
- context.register_builder(e, builder)
+ context.tweak_builder(e, features="cxx cxxshlib pyext bento",
+ defines=('__STDC_FORMAT_MACROS',))
View
@@ -2,6 +2,4 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
- context.register_builder("qhull", lambda e: default_builder(e, use="FLAPACK CLIB"))
- #context.register_builder("qhull", lambda e: default_builder(e, use="FLAPACK"))
+ context.tweak_builder("qhull", use="FLAPACK CLIB")
View
@@ -2,22 +2,13 @@ from bento.commands import hooks
@hooks.pre_build
def pre_build(context):
- default_builder = context.default_builder
+ context.tweak_builder("orthogonal_eval", use="NPYMATH")
+ context.tweak_builder("lambertw", use="NPYMATH")
+ context.tweak_builder("_logit", use="NPYMATH")
- def builder(extension):
- return default_builder(extension, use="NPYMATH")
- context.register_builder("orthogonal_eval", builder)
- context.register_builder("lambertw", builder)
- context.register_builder("_logit", builder)
+ context.tweak_builder("specfun", features="c fc pyext cshlib bento f2py",
+ use="sc_specfunlib NPYMATH CLIB")
- def builder(extension):
- return default_builder(extension,
- features="c fc pyext cshlib bento f2py",
- use="sc_specfunlib NPYMATH CLIB")
- context.register_builder("specfun", builder)
-
- def builder(extension):
- return default_builder(extension,
- use="sc_amos sc_toms sc_c_misc sc_cephes sc_mach " \
- "sc_cdf sc_specfunlib NPYMATH CLIB")
- context.register_builder("_cephes", builder)
+ context.tweak_builder("_cephes",
+ use="sc_amos sc_toms sc_c_misc sc_cephes sc_mach " \
+ "sc_cdf sc_specfunlib NPYMATH CLIB")
View
@@ -8,20 +8,9 @@ def pre_build(context):
return default_builder(extension, features="c cstlib pyext bento")
context.register_compiled_library_builder("statlibimp", builder)
- def builder(extension):
- return default_builder(extension,
- features="c fc cshlib pyext bento f2py",
- use="statlibimp CLIB")
- context.register_builder("statlib", builder)
-
- def builder(extension):
- return default_builder(extension,
- features="c fc cshlib pyext bento f2py",
- use="CLIB")
- context.register_builder("mvn", builder)
-
- def builder(extension):
- return default_builder(extension,
- features="c fc cshlib pyext bento f2py f2py_fortran",
- use="CLIB")
- context.register_builder("futil", builder)
+ context.tweak_builder("statlib", features="c fc cshlib pyext bento f2py",
+ use="statlibimp CLIB")
+ context.tweak_builder("mvn", features="c fc cshlib pyext bento f2py",
+ use="CLIB")
+ context.tweak_builder("futil", features="c fc cshlib pyext bento f2py f2py_fortran",
+ use="CLIB")

0 comments on commit 56971c5

Please sign in to comment.