Allow find_libraries to accept lists or strings (#3363)
* Allow find_libraries to accept lists or strings * Convert one more example from list to string
This commit is contained in:
parent
192a4b30f0
commit
a2d70a45fb
@ -568,20 +568,22 @@ def find_libraries(args, root, shared=True, recurse=False):
|
||||
"""Returns an iterable object containing a list of full paths to
|
||||
libraries if found.
|
||||
|
||||
Args:
|
||||
args: iterable object containing a list of library names to \
|
||||
search for (e.g. 'libhdf5')
|
||||
root: root folder where to start searching
|
||||
shared: if True searches for shared libraries, otherwise for static
|
||||
recurse: if False search only root folder, if True descends top-down \
|
||||
from the root
|
||||
:param args: Library name(s) to search for
|
||||
:type args: str or collections.Sequence
|
||||
:param str root: The root directory to start searching from
|
||||
:param bool shared: if True searches for shared libraries,
|
||||
otherwise for static
|
||||
:param bool recurse: if False search only root folder,
|
||||
if True descends top-down from the root
|
||||
|
||||
Returns:
|
||||
list of full paths to the libraries that have been found
|
||||
:returns: The libraries that have been found
|
||||
:rtype: LibraryList
|
||||
"""
|
||||
if not isinstance(args, collections.Sequence) or isinstance(args, str):
|
||||
message = '{0} expects a sequence of strings as first argument'
|
||||
message += ' [got {1} instead]'
|
||||
if isinstance(args, str):
|
||||
args = [args]
|
||||
elif not isinstance(args, collections.Sequence):
|
||||
message = '{0} expects a string or sequence of strings as the '
|
||||
message += 'first argument [got {1} instead]'
|
||||
raise TypeError(message.format(find_libraries.__name__, type(args)))
|
||||
|
||||
# Construct the right suffix for the library
|
||||
|
@ -767,7 +767,7 @@ def _libs_default_handler(descriptor, spec, cls):
|
||||
name = 'lib' + spec.name
|
||||
shared = '+shared' in spec
|
||||
return find_libraries(
|
||||
[name], root=spec.prefix, shared=shared, recurse=True
|
||||
name, root=spec.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
|
||||
|
@ -47,9 +47,9 @@ class Armadillo(Package):
|
||||
depends_on('hdf5', when='+hdf5')
|
||||
|
||||
def install(self, spec, prefix):
|
||||
arpack = find_libraries(['libarpack'], root=spec[
|
||||
arpack = find_libraries('libarpack', root=spec[
|
||||
'arpack-ng'].prefix.lib, shared=True)
|
||||
superlu = find_libraries(['libsuperlu'], root=spec[
|
||||
superlu = find_libraries('libsuperlu', root=spec[
|
||||
'superlu'].prefix, shared=False, recurse=True)
|
||||
cmake_args = [
|
||||
# ARPACK support
|
||||
|
@ -92,7 +92,7 @@ def install(self, spec, prefix):
|
||||
]
|
||||
fcflags = copy.deepcopy(optflags[self.spec.compiler.name])
|
||||
fcflags.append(spec['fftw'].cppflags)
|
||||
fftw = find_libraries(['libfftw3'], root=spec['fftw'].prefix.lib)
|
||||
fftw = find_libraries('libfftw3', root=spec['fftw'].prefix.lib)
|
||||
ldflags = [fftw.search_flags]
|
||||
libs = [
|
||||
join_path(spec['libint'].prefix.lib, 'libint.so'),
|
||||
|
@ -82,7 +82,7 @@ class Elemental(CMakePackage):
|
||||
def elemental_libs(self):
|
||||
shared = True if '+shared' in self.spec else False
|
||||
return find_libraries(
|
||||
['libEl'], root=self.prefix, shared=shared, recurse=True
|
||||
'libEl', root=self.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
def build_type(self):
|
||||
|
@ -74,14 +74,14 @@ def patch(self):
|
||||
def blas_libs(self):
|
||||
shared = True if '+shared' in self.spec else False
|
||||
return find_libraries(
|
||||
['libblas'], root=self.prefix, shared=shared, recurse=True
|
||||
'libblas', root=self.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
@property
|
||||
def lapack_libs(self):
|
||||
shared = True if '+shared' in self.spec else False
|
||||
return find_libraries(
|
||||
['liblapack'], root=self.prefix, shared=shared, recurse=True
|
||||
'liblapack', root=self.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
def install_one(self, spec, prefix, shared):
|
||||
|
@ -62,7 +62,7 @@ class NetlibScalapack(Package):
|
||||
def scalapack_libs(self):
|
||||
shared = True if '+shared' in self.spec else False
|
||||
return find_libraries(
|
||||
['libscalapack'], root=self.prefix, shared=shared, recurse=True
|
||||
'libscalapack', root=self.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
|
@ -38,7 +38,7 @@ class Octopus(Package):
|
||||
# Sample url is:
|
||||
# "http://www.tddft.org/programs/octopus/down.php?file=5.0.1/octopus-5.0.1.tar.gz"
|
||||
def url_for_version(self, version):
|
||||
return '{0}/{1}/octopus-{1}.tar.gz'.format(Octopus.base_url,
|
||||
return '{0}/{1}/octopus-{1}.tar.gz'.format(Octopus.base_url,
|
||||
version.dotted)
|
||||
|
||||
variant('scalapack', default=False,
|
||||
@ -69,7 +69,7 @@ def url_for_version(self, version):
|
||||
# feast, libfm, pfft, isf, pnfft
|
||||
|
||||
def install(self, spec, prefix):
|
||||
arpack = find_libraries(['libarpack'], root=spec[
|
||||
arpack = find_libraries('libarpack', root=spec[
|
||||
'arpack-ng'].prefix.lib, shared=True)
|
||||
lapack = spec['lapack'].libs
|
||||
blas = spec['blas'].libs
|
||||
@ -96,12 +96,12 @@ def install(self, spec, prefix):
|
||||
if '+netcdf' in spec:
|
||||
args.extend([
|
||||
'--with-netcdf-prefix=%s' % spec['netcdf-fortran'].prefix,
|
||||
'--with-netcdf-include=%s' %
|
||||
'--with-netcdf-include=%s' %
|
||||
spec['netcdf-fortran'].prefix.include,
|
||||
])
|
||||
if '+arpack-ng' in spec:
|
||||
args.extend([
|
||||
'--with-arpack={0}'.format(arpack.joined()),
|
||||
'--with-arpack={0}'.format(arpack.joined()),
|
||||
])
|
||||
if '+scalapack' in spec:
|
||||
args.extend([
|
||||
|
@ -60,7 +60,7 @@ class Openspeedshop(Package):
|
||||
"""
|
||||
|
||||
homepage = "http://www.openspeedshop.org"
|
||||
url = "https://github.com/OpenSpeedShop"
|
||||
url = "https://github.com/OpenSpeedShop"
|
||||
version('2.2', '16cb051179c2038de4e8a845edf1d573')
|
||||
# Use when the git repository is available
|
||||
version('2.3', branch='master',
|
||||
@ -230,7 +230,7 @@ def setup_environment(self, spack_env, run_env):
|
||||
# set the DYNINSTAPI_RT_LIB library which is
|
||||
# required for OpenSpeedShop to find loop level
|
||||
# performance information
|
||||
dyninst_libdir = find_libraries(['libdyninstAPI_RT'],
|
||||
dyninst_libdir = find_libraries('libdyninstAPI_RT',
|
||||
root=self.spec['dyninst'].prefix,
|
||||
shared=True, recurse=True)
|
||||
|
||||
@ -238,7 +238,7 @@ def setup_environment(self, spack_env, run_env):
|
||||
run_env.set('DYNINSTAPI_RT_LIB', dyninst_libdir)
|
||||
|
||||
# Find openspeedshop library path
|
||||
oss_libdir = find_libraries(['libopenss-framework'],
|
||||
oss_libdir = find_libraries('libopenss-framework',
|
||||
root=self.spec['openspeedshop'].prefix,
|
||||
shared=True, recurse=True)
|
||||
run_env.prepend_path('LD_LIBRARY_PATH',
|
||||
|
@ -47,7 +47,7 @@ class Veclibfort(Package):
|
||||
def libs(self):
|
||||
shared = True if '+shared' in self.spec else False
|
||||
return find_libraries(
|
||||
['libvecLibFort'], root=self.prefix, shared=shared, recurse=True
|
||||
'libvecLibFort', root=self.prefix, shared=shared, recurse=True
|
||||
)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
|
Loading…
Reference in New Issue
Block a user