diff --git a/bento.info b/bento.info index 972e9175bc85..55e417b3cdd2 100644 --- a/bento.info +++ b/bento.info @@ -34,8 +34,12 @@ Classifiers: Operating System :: Unix, Operating System :: MacOS +Recurse: + numpy/core + HookFile: - bscript + bscript, + numpy/core/bscript ExtraSourceFiles: numpy_templates.py, diff --git a/bscript b/bscript index b2aff026e226..b51b6084d255 100644 --- a/bscript +++ b/bscript @@ -1,5 +1,10 @@ import sys +# Ugly but necessary hack: import numpy here so that wscript in sub directories +# will see this numpy and not an already installed one +import __builtin__ +__builtin__.__NUMPY_SETUP__ = True + from bento.commands.hooks \ import \ pre_configure diff --git a/numpy/core/bento.info b/numpy/core/bento.info new file mode 100644 index 000000000000..378d7dce433d --- /dev/null +++ b/numpy/core/bento.info @@ -0,0 +1,22 @@ +Library: + CompiledLibrary: npymath + Sources: + src/npymath/_signbit.c, + src/npymath/ieee754.c.src, + src/npymath/npy_math.c.src, + src/npymath/npy_math_complex.c.src + Extension: multiarray + Sources: + src/multiarray/multiarraymodule_onefile.c + Extension: multiarray_tests + Sources: + src/multiarray/multiarray_tests.c.src + Extension: _sort + Sources: + src/_sortmodule.c.src + Extension: umath + Sources: + src/umath/umathmodule_onefile.c + Extension: scalarmath + Sources: + src/scalarmathmodule.c.src diff --git a/numpy/core/bscript b/numpy/core/bscript new file mode 100644 index 000000000000..c798ffe7b68b --- /dev/null +++ b/numpy/core/bscript @@ -0,0 +1,35 @@ +from bento.commands.hooks \ + import \ + pre_configure +import waflib + +# Importing this adds new checkers to waf configure context - I don't like this +# way of working, should find a more explicit way to attach new functions to +# context. +import numpy.waf_utils + +from setup_common \ + import \ + OPTIONAL_STDFUNCS_MAYBE, OPTIONAL_STDFUNCS, C99_FUNCS_EXTENDED, \ + C99_FUNCS_SINGLE, C99_COMPLEX_TYPES, C99_COMPLEX_FUNCS, \ + MANDATORY_FUNCS, C_ABI_VERSION, C_API_VERSION + +NUMPYCONFIG_SYM = [] + +# FIXME +NUMPYCONFIG_SYM.append(('DEFINE_NPY_ENABLE_SEPARATE_COMPILATION', '')) +NUMPYCONFIG_SYM.append(('VISIBILITY_HIDDEN', '')) + +NUMPYCONFIG_SYM.append(('NPY_ABI_VERSION', '0x%.8X' % C_ABI_VERSION)) +NUMPYCONFIG_SYM.append(('NPY_API_VERSION', '0x%.8X' % C_API_VERSION)) + +@pre_configure() +def configure(context): + conf = context.waf_context + + try: + conf.check_header("endian.h") + NUMPYCONFIG_SYM.append(('DEFINE_NPY_HAVE_ENDIAN_H', + '#define NPY_HAVE_ENDIAN_H 1')) + except waflib.Errors.ConfigurationError: + NUMPYCONFIG_SYM.append(('DEFINE_NPY_HAVE_ENDIAN_H', '')) diff --git a/numpy/waf_utils/__init__.py b/numpy/waf_utils/__init__.py new file mode 100644 index 000000000000..17bf8b00916c --- /dev/null +++ b/numpy/waf_utils/__init__.py @@ -0,0 +1,79 @@ +import os +import re + +import waflib.Configure +import waflib.Tools.c_config +from waflib import Logs, Utils + +DEFKEYS = waflib.Tools.c_config.DEFKEYS +DEFINE_COMMENTS = "define_commentz" + +def to_header(dct): + if 'header_name' in dct: + dct = Utils.to_list(dct['header_name']) + return ''.join(['#include <%s>\n' % x for x in dct]) + return '' + +# Make the given string safe to be used as a CPP macro +def sanitize_string(s): + key_up = s.upper() + return re.sub('[^A-Z0-9_]', '_', key_up) + +def validate_arguments(self, kw): + if not 'env' in kw: + kw['env'] = self.env.derive() + if not "compile_mode" in kw: + kw["compile_mode"] = "c" + if not 'compile_filename' in kw: + kw['compile_filename'] = 'test.c' + \ + ((kw['compile_mode'] == 'cxx') and 'pp' or '') + if not 'features' in kw: + kw['features'] = [kw['compile_mode']] + if not 'execute' in kw: + kw['execute'] = False + if not 'okmsg' in kw: + kw['okmsg'] = 'yes' + if not 'errmsg' in kw: + kw['errmsg'] = 'no !' + +def try_compile(self, kw): + self.start_msg(kw["msg"]) + ret = None + try: + ret = self.run_c_code(**kw) + except self.errors.ConfigurationError as e: + self.end_msg(kw['errmsg'], 'YELLOW') + if Logs.verbose > 1: + raise + else: + self.fatal('The configuration failed') + else: + kw['success'] = ret + self.end_msg(self.ret_msg(kw['okmsg'], kw)) + +@waflib.Configure.conf +def check_header(self, header_name, **kw): + code = """ +%s + +int main() +{ +} +""" % to_header({"header_name": header_name}) + + kw["code"] = code + kw["define_comment"] = "/* Define to 1 if you have the `%s' header. */" % header_name + kw["define_name"] = "HAVE_%s" % sanitize_string(header_name) + if not "features" in kw: + kw["features"] = ["c"] + kw["msg"] = "Checking for header %r" % header_name + + validate_arguments(self, kw) + try_compile(self, kw) + ret = kw["success"] + + self.post_check(**kw) + if not kw.get('execute', False): + return ret == 0 + return ret +