[Numpy-svn] r4706 - branches/build_with_scons/numpy/core

numpy-svn@scip... numpy-svn@scip...
Tue Jan 8 06:18:52 CST 2008


Author: cdavid
Date: 2008-01-08 06:18:46 -0600 (Tue, 08 Jan 2008)
New Revision: 4706

Modified:
   branches/build_with_scons/numpy/core/SConstruct
   branches/build_with_scons/numpy/core/scons_support.py
Log:
Refactor the check for m library + functions in numpy.core SConstruct

Modified: branches/build_with_scons/numpy/core/SConstruct
===================================================================
--- branches/build_with_scons/numpy/core/SConstruct	2008-01-08 05:50:36 UTC (rev 4705)
+++ branches/build_with_scons/numpy/core/SConstruct	2008-01-08 12:18:46 UTC (rev 4706)
@@ -1,4 +1,4 @@
-# Last Change: Sun Jan 06 10:00 PM 2008 J
+# Last Change: Tue Jan 08 09:00 PM 2008 J
 # vim:syntax=python
 import os
 import sys
@@ -11,7 +11,8 @@
 from numscons import write_info
 
 from scons_support import CheckBrokenMathlib, define_no_smp, \
-    generate_config_header, generate_config_header_emitter
+    generate_config_header, generate_config_header_emitter, \
+    check_mlib, check_mlibs
 
 env = GetNumpyEnvironment(ARGUMENTS)
 env.Append(CPPPATH = [get_python_inc()])
@@ -26,7 +27,7 @@
 #=======================
 # XXX: separate env for configuration
 config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib,
-    'CheckCBLAS' : CheckCBLAS})
+    'CheckCBLAS' : CheckCBLAS}, config_h = 'scons_config.h')
 
 # Convention: list of tuples (definition, value). value:
 # - 0: #undef definition
@@ -86,16 +87,9 @@
 mathlib = os.environ.get('MATHLIB')
 if mathlib: 
     mlibs.insert(0, mathlib)
-for mlib in mlibs:
-    st = config.CheckBrokenMathlib(mlib)
-    if st:
-        break
 
-if not st:
-    import SCons
-    raise SCons.Errors.UserError("No usable mathlib was found: chose another "\
-                                 "one using the MATHLIB env variable, eg "\
-                                 "'MATHLIB=m python setup.py build'")
+mlib = check_mlibs(config, mlibs)
+
 # XXX: this is ugly: mathlib has nothing to do in a public header file
 config_sym.append(('MATHLIB', ','.join(mlib)))
 
@@ -103,7 +97,7 @@
     """Check that f is available in mlib, and add the symbol appropriately.
 
     f is expected to be a tuble (symbol, cpp define)."""
-    st = config.CheckLibWithHeader(mlib, 'math.h', language = 'C', call = '%s;' % f[0], autoadd = autoadd)
+    st = config.CheckFunc(f[0], language = 'C')
     if st:
         config_sym.append((f[1], 1))
     else:

Modified: branches/build_with_scons/numpy/core/scons_support.py
===================================================================
--- branches/build_with_scons/numpy/core/scons_support.py	2008-01-08 05:50:36 UTC (rev 4705)
+++ branches/build_with_scons/numpy/core/scons_support.py	2008-01-08 12:18:46 UTC (rev 4706)
@@ -1,4 +1,4 @@
-#! Last Change: Sun Jan 06 09:00 PM 2008 J
+#! Last Change: Tue Jan 08 08:00 PM 2008 J
 
 __docstring__ = """Code to support special facilities to scons which are only
 useful for numpy.core, hence not put into numpy.distutils.scons"""
@@ -18,6 +18,7 @@
 from numscons.core.utils import rsplit, isstring
 
 import SCons.Node
+import SCons
 
 def split_ext(string):
     sp = rsplit(string, '.', 1)
@@ -160,6 +161,31 @@
         context.Result(' No !')
     return st[0]
 
+def check_mlib(config, mlib):
+    """Return 1 if mlib is available and usable by numpy, 0 otherwise.
+
+    mlib can be a string (one library), or a list of libraries."""
+    # Check the libraries in mlib are linkable
+    if len(mlib) > 0:
+        # XXX: put an autoadd argument to 0 here and add an autoadd argument to
+        # CheckBroekenMathlib (otherwise we may add bogus libraries, the ones
+        # which do not path the CheckBrokenMathlib test).
+        st = config.CheckLib(mlib)
+        if not st:
+            return 0
+    # Check the mlib is usable by numpy
+    return config.CheckBrokenMathlib(mlib)
+
+def check_mlibs(config, mlibs):
+    for mlib in mlibs:
+        if check_mlib(config, mlib):
+            return mlib
+
+    # No mlib was found.
+    raise SCons.Errors.UserError("No usable mathlib was found: chose another "\
+                                 "one using the MATHLIB env variable, eg "\
+                                 "'MATHLIB=m python setup.py build'")
+
 def define_no_smp():
     """Returns True if we should define NPY_NOSMP, False otherwise."""
     #--------------------------------



More information about the Numpy-svn mailing list