public
Last active

Numpy support for detecting libraries in several directories simultaneously (for numpy-1.6.1) see bug report at http://projects.scipy.org/numpy/ticket/993

  • Download Gist
system_info_patch-r2.diff
Diff
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 6dedf59..972a219 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -424,11 +424,7 @@ class system_info:
dirs = self.get_lib_dirs()
info = {}
for lib in libs:
- i = None
- for d in dirs:
- i = self.check_libs(d,[lib])
- if i is not None:
- break
+ i = self.check_libs(dirs,[lib])
if i is not None:
dict_append(info,**i)
else:
@@ -576,7 +572,7 @@ class system_info:
# exts.append('.so.3gf')
return exts
- def check_libs(self,lib_dir,libs,opt_libs =[]):
+ def check_libs(self,lib_dirs,libs,opt_libs =[]):
"""If static or shared libraries are available then return
their info dictionary.
@@ -586,23 +582,23 @@ class system_info:
exts = self.library_extensions()
info = None
for ext in exts:
- info = self._check_libs(lib_dir,libs,opt_libs,[ext])
+ info = self._check_libs(lib_dirs,libs,opt_libs,[ext])
if info is not None:
break
if not info:
- log.info(' libraries %s not found in %s', ','.join(libs), lib_dir)
+ log.info(' libraries %s not found in %s', ','.join(libs), lib_dirs)
return info
- def check_libs2(self, lib_dir, libs, opt_libs =[]):
+ def check_libs2(self, lib_dirs, libs, opt_libs =[]):
"""If static or shared libraries are available then return
their info dictionary.
Checks each library for shared or static.
"""
exts = self.library_extensions()
- info = self._check_libs(lib_dir,libs,opt_libs,exts)
+ info = self._check_libs(lib_dirs,libs,opt_libs,exts)
if not info:
- log.info(' libraries %s not found in %s', ','.join(libs), lib_dir)
+ log.info(' libraries %s not found in %s', ','.join(libs), lib_dirs)
return info
def _lib_list(self, lib_dir, libs, exts):
@@ -630,13 +626,36 @@ class system_info:
break
return liblist
- def _check_libs(self, lib_dir, libs, opt_libs, exts):
- found_libs = self._lib_list(lib_dir, libs, exts)
+ def _check_libs(self, lib_dirs, libs, opt_libs, exts):
+ """Find mandatory and optional libs in expected paths.
+
+ Missing optional libraries are silently forgotten.
+ """
+ # First, try to find the mandatory libraries
+ if is_sequence(lib_dirs):
+ found_libs, found_dirs = [], []
+ for dir_ in lib_dirs:
+ found_libs1 = self._lib_list(dir_, libs, exts)
+ if found_libs1:
+ found_libs.extend(found_libs1)
+ found_dirs.append(dir_)
+ else:
+ found_libs = self._lib_list(lib_dirs, libs, exts)
+ found_dirs = [lib_dirs]
if len(found_libs) == len(libs):
- info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}
- opt_found_libs = self._lib_list(lib_dir, opt_libs, exts)
- if len(opt_found_libs) == len(opt_libs):
- info['libraries'].extend(opt_found_libs)
+ info = {'libraries' : found_libs, 'library_dirs' : found_dirs}
+ # Now, check for optional libraries
+ if is_sequence(lib_dirs):
+ for dir_ in lib_dirs:
+ opt_found_libs = self._lib_list(dir_, opt_libs, exts)
+ if opt_found_libs:
+ if dir_ not in found_dirs:
+ found_dirs.extend(dir_)
+ found_libs.extend(opt_found_libs)
+ else:
+ opt_found_libs = self._lib_list(lib_dirs, opt_libs, exts)
+ if opt_found_libs:
+ found_libs.extend(opt_found_libs)
return info
else:
return None
@@ -685,12 +704,7 @@ class fftw_info(system_info):
incl_dirs = self.get_include_dirs()
incl_dir = None
libs = self.get_libs(self.section+'_libs', ver_param['libs'])
- info = None
- for d in lib_dirs:
- r = self.check_libs(d,libs)
- if r is not None:
- info = r
- break
+ info = self.check_libs(lib_dirs,libs)
if info is not None:
flag = 0
for d in incl_dirs:
@@ -861,23 +875,18 @@ class mkl_info(system_info):
#l = 'mkl_ia32'
if l not in self._lib_mkl:
self._lib_mkl.insert(0,l)
- system_info.__init__(self,
- default_lib_dirs=[os.path.join(mklroot,'lib',plt)],
- default_include_dirs=[os.path.join(mklroot,'include')])
+ system_info.__init__(
+ self,
+ default_lib_dirs=[os.path.join(mklroot,'lib',plt)],
+ default_include_dirs=[os.path.join(mklroot,'include')])
def calc_info(self):
lib_dirs = self.get_lib_dirs()
incl_dirs = self.get_include_dirs()
mkl_libs = self.get_libs('mkl_libs',self._lib_mkl)
- mkl = None
- for d in lib_dirs:
- mkl = self.check_libs2(d,mkl_libs)
- if mkl is not None:
- break
- if mkl is None:
+ info = self.check_libs2(lib_dirs,mkl_libs)
+ if info is None:
return
- info = {}
- dict_append(info,**mkl)
dict_append(info,
define_macros=[('SCIPY_MKL_H',None)],
include_dirs = incl_dirs)
@@ -940,12 +949,7 @@ class atlas_info(system_info):
lapack_atlas = self.check_libs2(d,['lapack_atlas'],[])
if atlas is not None:
lib_dirs2 = [d] + self.combine_paths(d,['atlas*','ATLAS*'])
- for d2 in lib_dirs2:
- lapack = self.check_libs2(d2,lapack_libs,[])
- if lapack is not None:
- break
- else:
- lapack = None
+ lapack = self.check_libs2(lib_dirs2,lapack_libs,[])
if lapack is not None:
break
if atlas:
@@ -1025,11 +1029,7 @@ class atlas_blas_info(atlas_info):
info = {}
atlas_libs = self.get_libs('atlas_libs',
self._lib_names + self._lib_atlas)
- atlas = None
- for d in lib_dirs:
- atlas = self.check_libs2(d,atlas_libs,[])
- if atlas is not None:
- break
+ atlas = self.check_libs2(lib_dirs,atlas_libs,[])
if atlas is None:
return
include_dirs = self.get_include_dirs()
@@ -1072,12 +1072,8 @@ class lapack_info(system_info):
lib_dirs = self.get_lib_dirs()
lapack_libs = self.get_libs('lapack_libs', self._lib_names)
- for d in lib_dirs:
- lapack = self.check_libs(d,lapack_libs,[])
- if lapack is not None:
- info = lapack
- break
- else:
+ info = self.check_libs(lib_dirs,lapack_libs_libs,[])
+ if info is None:
return
info['language'] = 'f77'
self.set_info(**info)
@@ -1441,12 +1437,8 @@ class blas_info(system_info):
lib_dirs = self.get_lib_dirs()
blas_libs = self.get_libs('blas_libs', self._lib_names)
- for d in lib_dirs:
- blas = self.check_libs(d,blas_libs,[])
- if blas is not None:
- info = blas
- break
- else:
+ info = self.check_libs(lib_dirs,blas_libs,[])
+ if info is None:
return
info['language'] = 'f77' # XXX: is it generally true?
self.set_info(**info)
@@ -1518,11 +1510,8 @@ class x11_info(system_info):
lib_dirs = self.get_lib_dirs()
include_dirs = self.get_include_dirs()
x11_libs = self.get_libs('x11_libs', ['X11'])
- for lib_dir in lib_dirs:
- info = self.check_libs(lib_dir, x11_libs, [])
- if info is not None:
- break
- else:
+ info = self.check_libs(lib_dirs, x11_libs, [])
+ if info is None:
return
inc_dir = None
for d in include_dirs:
@@ -1869,12 +1858,8 @@ class amd_info(system_info):
lib_dirs = self.get_lib_dirs()
amd_libs = self.get_libs('amd_libs', self._lib_names)
- for d in lib_dirs:
- amd = self.check_libs(d,amd_libs,[])
- if amd is not None:
- info = amd
- break
- else:
+ info = self.check_libs(lib_dirs,amd_libs,[])
+ if info is None:
return
include_dirs = self.get_include_dirs()
@@ -1903,12 +1888,8 @@ class umfpack_info(system_info):
lib_dirs = self.get_lib_dirs()
umfpack_libs = self.get_libs('umfpack_libs', self._lib_names)
- for d in lib_dirs:
- umf = self.check_libs(d,umfpack_libs,[])
- if umf is not None:
- info = umf
- break
- else:
+ info = self.check_libs(lib_dirs,umfpack_libs,[])
+ if info is None:
return
include_dirs = self.get_include_dirs()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.