[Numpy-svn] r4321 - in branches/numpy.scons/numpy: core distutils/scons linalg

numpy-svn@scip... numpy-svn@scip...
Mon Oct 29 02:14:47 CDT 2007


Author: cdavid
Date: 2007-10-29 02:14:38 -0500 (Mon, 29 Oct 2007)
New Revision: 4321

Modified:
   branches/numpy.scons/numpy/core/SConstruct
   branches/numpy.scons/numpy/distutils/scons/custom_checkers.py
   branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
   branches/numpy.scons/numpy/distutils/scons/libinfo.py
   branches/numpy.scons/numpy/linalg/SConstruct
Log:
Handle site.cfg in generic BLAS and LAPACK checkers

Modified: branches/numpy.scons/numpy/core/SConstruct
===================================================================
--- branches/numpy.scons/numpy/core/SConstruct	2007-10-29 04:21:06 UTC (rev 4320)
+++ branches/numpy.scons/numpy/core/SConstruct	2007-10-29 07:14:38 UTC (rev 4321)
@@ -1,4 +1,4 @@
-# Last Change: Mon Oct 29 01:00 PM 2007 J
+# Last Change: Mon Oct 29 03:00 PM 2007 J
 # vim:syntax=python
 import os
 import sys
@@ -141,21 +141,12 @@
 #--------------
 # Checking Blas
 #--------------
-config.CheckGenericBLAS()
-config.CheckGenericLAPACK()
-
-# TODO
 if config.CheckCBLAS():
     build_blasdot = 1
 else:
     build_blasdot = 0
 
 config.Finish()
-#config_f = open('config.log', 'r')
-#print "++++++++++ config.log dump ++++++++++++++++++"
-#for i in config_f:
-#    print i.strip('\n')
-#print "+++++++++++++++++++++++++++++++++++++++++++++"
 
 #==========
 #  Build

Modified: branches/numpy.scons/numpy/distutils/scons/custom_checkers.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/custom_checkers.py	2007-10-29 04:21:06 UTC (rev 4320)
+++ branches/numpy.scons/numpy/distutils/scons/custom_checkers.py	2007-10-29 07:14:38 UTC (rev 4321)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Mon Oct 29 01:00 PM 2007 J
+# Last Change: Mon Oct 29 03:00 PM 2007 J
 
 # Module for custom, common checkers for numpy (and scipy)
 import sys
@@ -209,21 +209,22 @@
         warning.warn('FIXME: LAPACK checks not implemented yet on win32')
         return 0
     else:
+        env = context.env
+
         # Get fortran stuff
-        # XXX: do not check if env variables are already here
-        if not CheckF77Mangling(context):
-            return 0
-        if not CheckF77Clib(context):
-            return 0
+        if not env.has_key('F77_NAME_MANGLER'):
+            if not CheckF77Mangling(context):
+                return 0
+        if not env.has_key('F77_LDFLAGS'):
+            if not CheckF77Clib(context):
+                return 0
 
-        env = context.env
-
         # Get the mangled name of our test function
         sgesv_string = env['F77_NAME_MANGLER']('sgesv')
         test_src = lapack_sgesv % sgesv_string
 
         # Check MKL
-        st = CheckMKL(context, autoadd)
+        st = CheckMKL(context, autoadd = 1)
         if st:
             fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
             fdict['LIBS'].append('lapack')
@@ -236,7 +237,7 @@
             return st
 
         # Check ATLAS
-        st = CheckATLAS(context, autoadd)
+        st = CheckATLAS(context, autoadd = 1)
         if st:
             fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
             fdict['LIBS'].append('lapack')
@@ -268,11 +269,15 @@
 
     return ret
 
-def CheckGenericBLAS(context):
-    # XXX: support site.cfg
-    libs = ['blas']
-    libpath = []
+def CheckGenericBLAS(context, autoadd = 1, section = 'blas'):
+    """Check whether a BLAS library can be found.
 
+    Use site.cfg if found."""
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if not found:
+        libs.extend(['blas'])
+
     env = context.env
     # Get fortran mangling
     if not env.has_key('F77_NAME_MANGLER'):
@@ -280,19 +285,28 @@
             return 0
 
     test_func_name = env['F77_NAME_MANGLER']('dgemm')
+    src = get_func_link_src(test_func_name)
 
-    src = get_func_link_src(test_func_name)
     context.Message("Checking for Generic BLAS... ")
-    st =  _my_try_link(context, src, libs, libpath, 0)
+
+    st =  _my_try_link(context, src, libs, libpath, autoadd)
+    if st:
+        env['F77_BLAS_LIBS'] = libs
+        env['F77_BLAS_LIBPATH'] = libpath
+
     context.Result(st)
 
     return st
 
-def CheckGenericLAPACK(context):
-    # XXX: support site.cfg
-    libs = ['lapack']
-    libpath = []
+def CheckGenericLAPACK(context, autoadd = 1, section = 'lapack'):
+    """Check whether a LAPACK library can be found.
 
+    Use site.cfg if found."""
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if not found:
+        libs.extend(['lapack'])
+
     env = context.env
     # Get fortran mangling
     if not env.has_key('F77_NAME_MANGLER'):
@@ -300,11 +314,15 @@
             return 0
 
     test_func_name = env['F77_NAME_MANGLER']('dpotri')
+    src = get_func_link_src(test_func_name)
 
-    src = get_func_link_src(test_func_name)
     context.Message("Checking for Generic LAPACK... ")
-    st =  _my_try_link(context, src, libs, libpath, 0)
+
+    st =  _my_try_link(context, src, libs, libpath, autoadd)
+    if st:
+        env['F77_LAPACK_LIBS'] = libs
+        env['F77_LAPACK_LIBPATH'] = libpath
+
     context.Result(st)
 
     return st
-

Modified: branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-10-29 04:21:06 UTC (rev 4320)
+++ branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-10-29 07:14:38 UTC (rev 4321)
@@ -1,4 +1,4 @@
-# Last Change: Fri Oct 26 06:00 PM 2007 J
+# Last Change: Mon Oct 29 03:00 PM 2007 J
 import os
 import sys
 import string

Modified: branches/numpy.scons/numpy/distutils/scons/libinfo.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/libinfo.py	2007-10-29 04:21:06 UTC (rev 4320)
+++ branches/numpy.scons/numpy/distutils/scons/libinfo.py	2007-10-29 07:14:38 UTC (rev 4321)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Mon Oct 29 12:00 PM 2007 J
+# Last Change: Mon Oct 29 03:00 PM 2007 J
 
 # Module for support to look for external code (replacement of
 # numpy.distutils.system_info). KEEP THIS INDEPENDANT OF SCONS !
@@ -9,6 +9,7 @@
 from numpy.distutils.system_info import default_lib_dirs, \
     default_include_dirs, default_src_dirs, get_standard_file
 
+# Think about a cache mechanism, to avoid reparsing the config file everytime.
 def get_config():
     """ This tries to read .cfg files in several locations, and merge its
     information into a ConfigParser object for the first found file.

Modified: branches/numpy.scons/numpy/linalg/SConstruct
===================================================================
--- branches/numpy.scons/numpy/linalg/SConstruct	2007-10-29 04:21:06 UTC (rev 4320)
+++ branches/numpy.scons/numpy/linalg/SConstruct	2007-10-29 07:14:38 UTC (rev 4321)
@@ -1,4 +1,4 @@
-# Last Change: Fri Oct 26 09:00 PM 2007 J
+# Last Change: Mon Oct 29 03:00 PM 2007 J
 # vim:syntax=python
 from numpy.distutils.misc_util import get_numpy_include_dirs, get_mathlibs
 from numpy.distutils.scons import GetNumpyEnvironment, scons_get_paths
@@ -10,6 +10,8 @@
 config = env.NumpyConfigure(custom_tests = 
     {'CheckLAPACK' : CheckLAPACK})
 
+use_lapack = config.CheckLAPACK()
+
 # XXX: this is ugly, better find the mathlibs with a checker 
 for i in scons_get_paths(env['include_bootstrap']):
     try:
@@ -19,7 +21,6 @@
         pass
 env.AppendUnique(LIBS = mlib)
 
-use_lapack = config.CheckLAPACK()
 config.Finish()
 
 sources = ['lapack_litemodule.c']



More information about the Numpy-svn mailing list