3
from __future__ import nested_scopes
7
from distutils.dep_util import newer_group, newer
9
from os.path import join
12
# To skip wrapping single precision atlas/lapack/blas routines, set
13
# the following flag to True:
14
skip_single_routines = 0
16
# Some OS distributions (e.g. Redhat, Suse) provide a blas library that
17
# is built using incomplete blas sources that come with lapack tar-ball.
18
# In order to use such a library in scipy.linalg, the following flag
19
# must be set to True:
24
tmpl_empty_cblas_pyf = '''
26
usercode void empty_module(void) {}
28
subroutine empty_module()
29
intent(c) empty_module
30
end subroutine empty_module
32
end python module cblas
35
def configuration(parent_package='',top_path=None):
36
from numpy.distutils.misc_util import Configuration
37
from numpy.distutils.system_info import get_info
39
config = Configuration('blas',parent_package,top_path)
41
blas_opt = get_info('blas_opt',notfound_action=2)
43
atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[]) \
44
if k=='ATLAS_INFO']+[None])[0]
46
print 'ATLAS version',atlas_version
49
skip_names = {'cblas':[],'fblas':[]}
50
if skip_single_routines:
52
skip_names['cblas'].extend('saxpy caxpy'.split())
53
skip_names['fblas'].extend(skip_names['cblas'])
54
skip_names['fblas'].extend(\
55
'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\
56
' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\
57
' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\
58
' sgemm cgemm'.split())
61
target_dir = join(target_dir,'blas')
62
skip_names['fblas'].extend(\
63
'drotmg srotmg drotm srotm'.split())
66
config.add_extension('fblas',
67
sources = ['fblas.pyf.src','fblaswrap.f.src'],
68
depends = [__file__,'fblas_l?.pyf.src'],
69
f2py_options = ['skip:']+skip_names['fblas']+[':'],
74
def get_cblas_source(ext, build_dir):
75
name = ext.name.split('.')[-1]
76
assert name=='cblas',`name`
77
if atlas_version is None:
78
target = join(build_dir,target_dir,'cblas.pyf')
79
from distutils.dep_util import newer
80
if newer(__file__,target):
82
f.write(tmpl_empty_cblas_pyf)
85
target = ext.depends[0]
86
assert os.path.basename(target)=='cblas.pyf.src'
89
config.add_extension('cblas',
90
sources = [get_cblas_source],
91
depends = ['cblas.pyf.src','cblas_l?.pyf.src'],
92
f2py_options = ['skip:']+skip_names['cblas']+[':'],
96
config.add_data_dir('tests')
100
if __name__ == '__main__':
101
from numpy.distutils.core import setup
102
setup(**configuration(top_path='').todict())