diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2017-03-04 11:23:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-04 11:23:57 -0600 |
commit | a2d70a45fbc2ee07160c3ee750dbffe9d4fd5b1b (patch) | |
tree | 9aa6fef670d837375a5219b17c0655ce0f7532ce /lib | |
parent | 192a4b30f0a08f3e05aad9accfe3bf42f7554759 (diff) | |
download | spack-a2d70a45fbc2ee07160c3ee750dbffe9d4fd5b1b.tar.gz spack-a2d70a45fbc2ee07160c3ee750dbffe9d4fd5b1b.tar.bz2 spack-a2d70a45fbc2ee07160c3ee750dbffe9d4fd5b1b.tar.xz spack-a2d70a45fbc2ee07160c3ee750dbffe9d4fd5b1b.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 28 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 79f15f9a21..7f6773266d 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -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 - - Returns: - list of full paths to the libraries that have been found + :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: 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 diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index c0ee8486db..9fc2c99e4a 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -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 ) |