Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.