forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BENTO: start numpy.core configuration
We also add configuration helpers in numpy.build_utils.
- Loading branch information
Showing
5 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', '')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|