~ubuntu-branches/ubuntu/raring/python-scipy/raring-proposed

« back to all changes in this revision

Viewing changes to Lib/lib/blas/setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-07 14:12:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070107141212-mm0ebkh5b37hcpzn
* Remove build dependency on python-numpy-dev.
* python-scipy: Depend on python-numpy instead of python-numpy-dev.
* Package builds on other archs than i386. Closes: #402783.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
from __future__ import nested_scopes
 
4
import os
 
5
import sys
 
6
import re
 
7
from distutils.dep_util import newer_group, newer
 
8
from glob import glob
 
9
from os.path import join
 
10
 
 
11
#-------------------
 
12
# To skip wrapping single precision atlas/lapack/blas routines, set
 
13
# the following flag to True:
 
14
skip_single_routines = 0
 
15
 
 
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:
 
20
using_lapack_blas = 0
 
21
 
 
22
#--------------------
 
23
 
 
24
tmpl_empty_cblas_pyf = '''
 
25
python module cblas
 
26
  usercode void empty_module(void) {}
 
27
  interface
 
28
    subroutine empty_module()
 
29
      intent(c) empty_module
 
30
    end subroutine empty_module
 
31
  end interface
 
32
end python module cblas
 
33
'''
 
34
 
 
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
 
38
 
 
39
    config = Configuration('blas',parent_package,top_path)
 
40
 
 
41
    blas_opt = get_info('blas_opt',notfound_action=2)
 
42
 
 
43
    atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[]) \
 
44
                      if k=='ATLAS_INFO']+[None])[0]
 
45
    if atlas_version:
 
46
        print 'ATLAS version',atlas_version
 
47
 
 
48
    target_dir = ''
 
49
    skip_names = {'cblas':[],'fblas':[]}
 
50
    if skip_single_routines:
 
51
        target_dir = 'dbl'
 
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())
 
59
 
 
60
    if using_lapack_blas:
 
61
        target_dir = join(target_dir,'blas')
 
62
        skip_names['fblas'].extend(\
 
63
            'drotmg srotmg drotm srotm'.split())
 
64
 
 
65
    # fblas:
 
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']+[':'],
 
70
                         extra_info = blas_opt
 
71
                         )
 
72
 
 
73
    # cblas:
 
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):
 
81
                f = open(target,'w')
 
82
                f.write(tmpl_empty_cblas_pyf)
 
83
                f.close()
 
84
        else:
 
85
            target = ext.depends[0]
 
86
            assert os.path.basename(target)=='cblas.pyf.src'
 
87
        return target
 
88
 
 
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']+[':'],
 
93
                         extra_info = blas_opt
 
94
                         )
 
95
 
 
96
    config.add_data_dir('tests')
 
97
 
 
98
    return config
 
99
 
 
100
if __name__ == '__main__':
 
101
    from numpy.distutils.core import setup
 
102
    setup(**configuration(top_path='').todict())