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
def configuration(parent_package='',parent_path=None):
25
from scipy_distutils.core import Extension
26
from scipy_distutils.misc_util import dot_join, get_path, default_config_dict
27
from scipy_distutils.system_info import get_info, dict_append, NotFoundError
29
from interface_gen import generate_interface
32
config = default_config_dict(package,parent_package)
33
local_path = get_path(__name__,parent_path)
34
def local_join(*paths):
35
return os.path.join(*((local_path,)+paths))
37
lapack_opt = get_info('lapack_opt')
40
raise NotFoundError,'no lapack/blas resources found'
42
atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \
43
if k=='ATLAS_INFO']+[None])[0]
45
print 'ATLAS version',atlas_version
48
skip_names = {'clapack':[],'flapack':[],'cblas':[],'fblas':[]}
49
if skip_single_routines:
51
skip_names['clapack'].extend(\
52
'sgesv cgesv sgetrf cgetrf sgetrs cgetrs sgetri cgetri'\
53
' sposv cposv spotrf cpotrf spotrs cpotrs spotri cpotri'\
54
' slauum clauum strtri ctrtri'.split())
55
skip_names['flapack'].extend(skip_names['clapack'])
56
skip_names['flapack'].extend(\
57
'sgesdd cgesdd sgelss cgelss sgeqrf cgeqrf sgeev cgeev'\
58
' sgegv cgegv ssyev cheev slaswp claswp sgees cgees'
59
' sggev cggev'.split())
60
skip_names['cblas'].extend('saxpy caxpy'.split())
61
skip_names['fblas'].extend(skip_names['cblas'])
62
skip_names['fblas'].extend(\
63
'srotg crotg srotmg srot csrot srotm sswap cswap sscal cscal'\
64
' csscal scopy ccopy sdot cdotu cdotc snrm2 scnrm2 sasum scasum'\
65
' isamax icamax sgemv cgemv chemv ssymv strmv ctrmv'\
66
' sgemm cgemm'.split())
69
target_dir = join(target_dir,'blas')
70
skip_names['fblas'].extend(\
71
'drotmg srotmg drotm srotm'.split())
73
if atlas_version=='3.2.1_pre3.3.6':
74
target_dir = join(target_dir,'atlas321')
75
skip_names['clapack'].extend(\
76
'sgetri dgetri cgetri zgetri spotri dpotri cpotri zpotri'\
77
' slauum dlauum clauum zlauum strtri dtrtri ctrtri ztrtri'.split())
78
elif atlas_version>'3.4.0' and atlas_version<='3.5.12':
79
skip_names['clapack'].extend('cpotrf zpotrf'.split())
81
def generate_pyf(extension, build_dir):
82
name = extension.name.split('.')[-1]
83
target = join(build_dir,target_dir,name+'.pyf')
84
if name[0]=='c' and atlas_version is None and newer(__file__,target):
86
f.write('python module '+name+'\n')
87
f.write('usercode void empty_module(void) {}\n')
88
f.write('interface\n')
89
f.write('subroutine empty_module()\n')
90
f.write('intent(c) empty_module\n')
91
f.write('end subroutine empty_module\n')
92
f.write('end interface\nend python module'+name+'\n')
95
if newer_group(extension.depends,target):
96
generate_interface(name,
103
ext_args = {'name': dot_join(parent_package,package,'fblas'),
104
'sources': [generate_pyf,
105
local_join('src','fblaswrap.f')],
106
'depends': map(local_join,['generic_fblas.pyf',
107
'generic_fblas1.pyf',
108
'generic_fblas2.pyf',
109
'generic_fblas3.pyf',
112
dict_append(ext_args,**lapack_opt)
113
ext = Extension(**ext_args)
114
config['ext_modules'].append(ext)
117
ext_args = {'name': dot_join(parent_package,package,'cblas'),
118
'sources': [generate_pyf],
119
'depends': map(local_join,['generic_cblas.pyf',
120
'generic_cblas1.pyf',
123
dict_append(ext_args,**lapack_opt)
124
ext = Extension(**ext_args)
125
config['ext_modules'].append(ext)
128
ext_args = {'name': dot_join(parent_package,package,'flapack'),
129
'sources': [generate_pyf],
130
'depends': map(local_join,['generic_flapack.pyf',
131
'flapack_user_routines.pyf',
134
dict_append(ext_args,**lapack_opt)
135
ext = Extension(**ext_args)
136
config['ext_modules'].append(ext)
139
ext_args = {'name': dot_join(parent_package,package,'clapack'),
140
'sources': [generate_pyf],
141
'depends': map(local_join,['generic_clapack.pyf',
144
dict_append(ext_args,**lapack_opt)
145
ext = Extension(**ext_args)
146
config['ext_modules'].append(ext)
149
ext_args = {'name':dot_join(parent_package,package,'_flinalg'),
150
'sources':[local_join('src','det.f'),
151
local_join('src','lu.f')]
153
dict_append(ext_args,**lapack_opt)
154
config['ext_modules'].append(Extension(**ext_args))
157
ext_args = {'name':dot_join(parent_package,package,'calc_lwork'),
158
'sources':[local_join('src','calc_lwork.f')],
160
dict_append(ext_args,**lapack_opt)
161
config['ext_modules'].append(Extension(**ext_args))
164
ext_args = {'name':dot_join(parent_package,package,'atlas_version'),
165
'sources':[os.path.join(local_path,'atlas_version.c')]}
166
dict_append(ext_args,**lapack_opt)
167
ext = Extension(**ext_args)
168
config['ext_modules'].append(ext)
171
methods = ['BiCGREVCOM.f.src',
172
'BiCGSTABREVCOM.f.src',
175
# 'ChebyREVCOM.f.src',
177
# 'JacobiREVCOM.f.src',
181
Util = ['STOPTEST2.f.src','getbreak.f.src']
182
sources = Util + methods + ['_iterative.pyf.src']
184
'name': dot_join(parent_package,package,'_iterative'),
185
'sources': [local_join('iterative',x) for x in sources]
187
dict_append(ext_args, **lapack_opt)
188
ext = Extension(**ext_args)
189
config['ext_modules'].append(ext)
193
if __name__ == '__main__':
194
from scipy_distutils.core import setup
195
from linalg_version import linalg_version
197
setup(version=linalg_version,
198
**configuration(parent_path=''))