1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """
25 This file defines a set of system_info classes for getting
26 information about various resources (libraries, library directories,
27 include directories, etc.) in the system. It is an extension of
28 numpy's system_info.py. Currently, the following classes are
29 available:
30
31 numpy_blas
32 <all other classes supported by numpy>
33
34 Usage:
35 info_dict = get_info(<name>)
36 where <name> is a string 'numpy_blas', etc.
37 For a complete list of allowed names, see the definition of get_info()
38 function below.
39
40 Returned info_dict is a dictionary which is compatible with
41 distutils.setup keyword arguments. If info_dict == {}, then the
42 asked resource is not available (system_info could not find it).
43
44 Several *_info classes specify an environment variable to specify
45 the locations of software. When setting the corresponding environment
46 variable to 'None' then the software will be ignored, even when it
47 is available in system.
48
49 Modified from numpy's original system_info.py by:
50 Minh-Tri Pham <mtpham@ntu.edu.sg>, July 2007
51 """
52
53 __all__ = ['get_info', 'default_dir']
54
55 import os
56 import re
57
58 from numpy.distutils import system_info as npsi
59 from numpy.distutils.ccompiler import get_default_compiler
60 from numpy.distutils.cpuinfo import cpu
61 from distutils.version import StrictVersion
62 from scipy.weave import catalog
63
64
66 out = os.popen('gcc -dumpversion','r')
67 out_string = out.read()
68 out.close()
69 result = re.search('(\d+\.\d+)',out_string)
70 if result:
71 return StrictVersion(result.group(1))
72 return None
73
74
75
77 """
78 notfound_action:
79 0 - do nothing
80 1 - display warning message
81 2 - raise error
82 """
83 cl = {
84 'numpy_blas':numpy_blas_info,
85 }.get(name.lower())
86 if cl is None:
87 return npsi.get_info(name,notfound_action)
88 return cl().get_info(notfound_action)
89
92 """ Return a dictonary with items that are compatible
93 with numpy.distutils.setup keyword arguments.
94 """
95
96 info = npsi.get_info('blas_opt')
97 for x in ['define_macros', 'include_dirs', 'libraries', 'library_dirs', \
98 'extra_compiler_args']:
99 if not info.has_key(x):
100 info[x] = []
101 if len(npsi.get_info('atlas')):
102 info['define_macros'].append(('HAS_ATLAS', None))
103
104
105 extra_args = []
106 dcomp = get_default_compiler()
107 if cpu._has_sse2() and (dcomp == 'mingw32' or dcomp == 'gcc'):
108 extra_args = ['-O3', '-msse2', '-mfpmath=sse', '-malign-double']
109 if get_gcc_version() >= '4.2':
110 extra_args.append('-mtune=generic')
111 else:
112 extra_args.append('-march=pentium4')
113 extra_args.append('-mtune=pentium4')
114 info['extra_compiler_args'].extend(extra_args)
115
116 return info
117
118
120 """
121 Return a default location to store wisdom files and catalogs.
122
123 The default location is a sub-folder called '.pycv_wisdom' of
124 SciPy's default location in Weave
125
126 :Remarks:
127 I admit I use SciPy's default directory to avoid all the troubles
128 of locating a default folder to store intermediate results.
129 I hope the community will forgive me.
130 """
131
132
133 if hasattr(default_dir,"cached_path") and \
134 os.path.exists(default_dir.cached_path):
135 return default_dir.cached_path
136
137
138 def_dir = catalog.default_dir()
139
140
141 path = os.path.join(os.path.split(def_dir)[0], '.pycv_wisdom')
142
143 if not os.path.exists(path):
144 catalog.create_dir(path)
145 os.chmod(path,0700)
146 if not catalog.is_writable(path):
147 print 'warning: default directory is not write accessible.'
148 print 'default:', path
149
150
151
152 default_dir.cached_path = path
153
154 return path
155
156
157
158
159 if __name__ == "__main__":
160 npsi.show_all()
161