[Scipy-svn] r3575 - branches/scipy.scons/scipy/lib/blas
scipy-svn at scipy.org
scipy-svn at scipy.org
Sat Nov 24 02:52:42 EST 2007
Author: cdavid
Date: 2007-11-24 01:49:23 -0600 (Sat, 24 Nov 2007)
New Revision: 3575
Added:
branches/scipy.scons/scipy/lib/blas/SConstruct
Modified:
branches/scipy.scons/scipy/lib/blas/setupscons.py
Log:
lib/blas now build with scons
Copied: branches/scipy.scons/scipy/lib/blas/SConstruct (from rev 3574, branches/scipy.scons/scipy/linalg/SConstruct)
===================================================================
--- branches/scipy.scons/scipy/linalg/SConstruct 2007-11-24 03:59:04 UTC (rev 3574)
+++ branches/scipy.scons/scipy/lib/blas/SConstruct 2007-11-24 07:49:23 UTC (rev 3575)
@@ -0,0 +1,81 @@
+# Last Change: Sat Nov 24 04:00 PM 2007 J
+# vim:syntax=python
+
+import os
+from os.path import join as pjoin, splitext
+
+from numpy.distutils.misc_util import get_numpy_include_dirs
+from numpy.distutils.scons import get_python_inc#, get_pythonlib_dir
+from numpy.distutils.scons import GetNumpyEnvironment
+from numpy.distutils.scons import CheckCBLAS, CheckF77BLAS,\
+ IsVeclib, IsAccelerate, \
+ IsATLAS, GetATLASVersion
+
+from numpy.distutils.scons.configuration import write_info
+
+env = GetNumpyEnvironment(ARGUMENTS)
+env.Append(CPPPATH = [get_python_inc(), get_numpy_include_dirs()])
+#if os.name == 'nt':
+# # NT needs the pythonlib to run any code importing Python.h, including
+# # simple code using only typedef and so on, so we need it for configuration
+# # checks
+# env.AppendUnique(LIBPATH = [get_pythonlib_dir()])
+
+#=======================
+# Starting Configuration
+#=======================
+config = env.NumpyConfigure(custom_tests = {'CheckCBLAS' : CheckCBLAS,
+ 'CheckBLAS' : CheckF77BLAS})
+
+#--------------
+# Checking Blas
+#--------------
+st = config.CheckBLAS(check_version = 1)
+if not st:
+ raise RuntimeError("no blas found, necessary for linalg module")
+if IsATLAS(env, 'blas'):
+ version = GetATLASVersion(env, 'blas')
+ env.Append(CPPDEFINES = [('ATLAS_INFO', '"\\"%s"\\"' % version)])
+else:
+ env.Append(CPPDEFINES = [('NO_ATLAS_INFO', 1)])
+
+if config.CheckCBLAS():
+ has_cblas = 1
+else:
+ has_cblas = 0
+
+config.Finish()
+write_info(env)
+
+#==========
+# Build
+#==========
+
+# XXX: handle cblas wrapper for complex (check in numpy.scons or here ?)
+env.AppendUnique(CPPPATH = env['F2PYINCLUDEDIR'])
+env.AppendUnique(F2PYOPTIONS = '--quiet')
+
+#------------
+# fblas
+#------------
+env.NumpyFromFTemplate('fblas.pyf', 'fblas.pyf.src')
+source = ['fblas.pyf']
+if IsVeclib(env, 'blas') or IsAccelerate(env, 'blas'):
+ env.NumpyFromCTemplate('fblaswrap_veclib_c.c', 'fblaswrap_veclib_c.c.src')
+ source.append('fblaswrap_veclib_c.c')
+else:
+ env.NumpyFromFTemplate('fblaswrap.f', 'fblaswrap.f.src')
+ source.append('fblaswrap.f')
+env.NumpyPythonExtension('fblas', source)
+
+#------------
+# cblas
+#------------
+source = ['cblas.pyf']
+if has_cblas:
+ env.NumpyFromFTemplate('cblas.pyf', 'cblas.pyf.src')
+env.NumpyPythonExtension('cblas', source)
+# env.haha('cblas', 'generic_cblas.pyf')
+# else:
+# env.hihi('cblas', 'generic_cblas.pyf')
+# env.NumpyPythonExtension('cblas', source = 'cblas.pyf')
Modified: branches/scipy.scons/scipy/lib/blas/setupscons.py
===================================================================
--- branches/scipy.scons/scipy/lib/blas/setupscons.py 2007-11-24 03:59:04 UTC (rev 3574)
+++ branches/scipy.scons/scipy/lib/blas/setupscons.py 2007-11-24 07:49:23 UTC (rev 3575)
@@ -1,119 +1,12 @@
#!/usr/bin/env python
-from __future__ import nested_scopes
-import os
-import sys
-import re
-from distutils.dep_util import newer_group, newer
-from glob import glob
-from os.path import join
-
-#-------------------
-# To skip wrapping single precision atlas/lapack/blas routines, set
-# the following flag to True:
-skip_single_routines = 0
-
-# Some OS distributions (e.g. Redhat, Suse) provide a blas library that
-# is built using incomplete blas sources that come with lapack tar-ball.
-# In order to use such a library in scipy.linalg, the following flag
-# must be set to True:
-using_lapack_blas = 0
-
-#--------------------
-
-def needs_cblas_wrapper(info):
- """Returns true if needs c wrapper around cblas for calling from
- fortran."""
- r_accel = re.compile("Accelerate")
- r_vec = re.compile("vecLib")
- res = False
- try:
- tmpstr = info['extra_link_args']
- for i in tmpstr:
- if r_accel.search(i) or r_vec.search(i):
- res = True
- except KeyError:
- pass
-
- return res
-
-tmpl_empty_cblas_pyf = '''
-python module cblas
- usercode void empty_module(void) {}
- interface
- subroutine empty_module()
- intent(c) empty_module
- end subroutine empty_module
- end interface
-end python module cblas
-'''
-
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info
config = Configuration('blas',parent_package,top_path)
- blas_opt = get_info('blas_opt',notfound_action=2)
-
- atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[]) \
- if k=='ATLAS_INFO']+[None])[0]
- if atlas_version:
- print 'ATLAS version',atlas_version
-
- target_dir = ''
- skip_names = {'cblas':[],'fblas':[]}
- if skip_single_routines:
- target_dir = 'dbl'
- skip_names['cblas'].extend('saxpy caxpy'.split())
- skip_names['fblas'].extend(skip_names['cblas'])
- skip_names['fblas'].extend(\
- 'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\
- ' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\
- ' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\
- ' sgemm cgemm'.split())
-
- if using_lapack_blas:
- target_dir = join(target_dir,'blas')
- skip_names['fblas'].extend(\
- 'drotmg srotmg drotm srotm'.split())
-
- depends = [__file__, 'fblas_l?.pyf.src', 'fblas.pyf.src','fblaswrap.f.src',
- 'fblaswrap_veclib_c.c.src']
- # fblas:
- if needs_cblas_wrapper(blas_opt):
- sources = ['fblas.pyf.src', 'fblaswrap_veclib_c.c.src'],
- else:
- sources = ['fblas.pyf.src','fblaswrap.f.src']
- config.add_extension('fblas',
- sources = sources,
- depends = depends,
- f2py_options = ['skip:']+skip_names['fblas']+[':'],
- extra_info = blas_opt
- )
- # cblas:
- def get_cblas_source(ext, build_dir):
- name = ext.name.split('.')[-1]
- assert name=='cblas',`name`
- if atlas_version is None:
- target = join(build_dir,target_dir,'cblas.pyf')
- from distutils.dep_util import newer
- if newer(__file__,target):
- f = open(target,'w')
- f.write(tmpl_empty_cblas_pyf)
- f.close()
- else:
- target = ext.depends[0]
- assert os.path.basename(target)=='cblas.pyf.src'
- return target
-
- config.add_extension('cblas',
- sources = [get_cblas_source],
- depends = ['cblas.pyf.src','cblas_l?.pyf.src'],
- f2py_options = ['skip:']+skip_names['cblas']+[':'],
- extra_info = blas_opt
- )
-
+ config.add_sconscript('SConstruct')
config.add_data_dir('tests')
return config
More information about the Scipy-svn
mailing list