Compare commits

...

17 Commits

Author SHA1 Message Date
Harmen Stoppels
39cf85ae26 wgl: find headers recursive 2024-11-12 09:52:21 +01:00
Harmen Stoppels
e035bd176a remove extension from find_headers call 2024-11-12 08:45:31 +01:00
Harmen Stoppels
925f4c3f1e python: do not use heuristic search 2024-11-12 08:40:24 +01:00
Harmen Stoppels
be2c0bb033 remove use of find_all_headers 2024-11-11 15:33:22 +01:00
Harmen Stoppels
b8c357556e docs: no longer recommend recursive=True 2024-11-11 12:56:26 +01:00
Harmen Stoppels
d20e3fbd84 fix a few odd packages 2024-11-11 12:51:16 +01:00
Harmen Stoppels
f20803ab3b increment find_headers search depth to 3 2024-11-11 12:41:43 +01:00
Harmen Stoppels
318db244c8 drop recursive=True from find_headers / find_libraries in builtin 2024-11-11 12:40:46 +01:00
Harmen Stoppels
4d979b0676 simplify api: recursive="heuristic" by default 2024-11-11 12:26:48 +01:00
Harmen Stoppels
a3dbbae861 Use .lower() when checking whether the current dir is a typical include or lib dir 2024-11-11 12:16:33 +01:00
Harmen Stoppels
4e72a09578 typo 2024-11-11 12:16:33 +01:00
Harmen Stoppels
9ed941b7d6 drop heuristic in find_all_headers 2024-11-11 12:16:33 +01:00
Harmen Stoppels
161b67fd09 Also move heuristics into find_headers directly 2024-11-11 12:16:33 +01:00
Harmen Stoppels
1a8d4e46e4 explicitly add ignored files 2024-11-11 12:16:33 +01:00
Harmen Stoppels
33e152accc move max_depth default into find_libraries 2024-11-11 12:16:33 +01:00
Harmen Stoppels
1da7ddc2b3 tests: improve file_list.py search order test
The directory structure was updated to have a typical ./include, ./lib,
./lib64 structure, otherwise the search heuristics of `find_libraries`
does not work. Also add a comment to tell what the test does, cause it
was unclear.
2024-11-11 12:16:33 +01:00
Harmen Stoppels
0ec918570a find_libraries: use targeted, iterative deepening with default max depth
Use some form of iterative deepening with early return in
`find_libraries`:

1. Search `<root>`, `<root>/{lib, lib64,...}` dirs at max depth 0 and
   return early if found.
2. Search `<root>/{lib, lib64,...}` dirs at max depth 1 and return early
   if found (covers e.g. `<root>/lib/x86_64-linux-gnu/` subdirs)
3. Fall back to exhaustive search up to `max_depth - 1` of
   `<root>/{lib, lib64, ...}`.

Set the default library search handler of `max_depth` to `4` to still
cover `<root>/lib/pythonX.Y/site-packages/<name>/`.
2024-11-11 12:16:33 +01:00
238 changed files with 370 additions and 414 deletions

View File

@ -3234,7 +3234,7 @@ as a ``@property`` in the package's class:
@property
def libs(self):
# The library provided by Foo is libMyFoo.so
return find_libraries("libMyFoo", root=self.home, recursive=True)
return find_libraries("libMyFoo", root=self.home)
A package may also provide a custom implementation of each attribute
for the virtual packages it provides by implementing the
@ -3288,22 +3288,22 @@ follows:
# Just the foo headers
@property
def headers(self):
return find_headers("foo", root=self.home.include, recursive=False)
return find_headers("foo", root=self.home)
# Just the foo libraries
@property
def libs(self):
return find_libraries("libFoo", root=self.home, recursive=True)
return find_libraries("libFoo", root=self.home)
# The header provided by the bar virtual package
@property
def bar_headers(self):
return find_headers("bar/bar.h", root=self.home.include, recursive=False)
return find_headers("bar", root=self.home)
# The library provided by the bar virtual package
@property
def bar_libs(self):
return find_libraries("libFooBar", root=self.home, recursive=True)
return find_libraries("libFooBar", root=self.home)
# The baz virtual package home
@property
@ -3313,12 +3313,12 @@ follows:
# The header provided by the baz virtual package
@property
def baz_headers(self):
return find_headers("baz/baz", root=self.baz_home.include, recursive=False)
return find_headers("baz", root=self.baz_home)
# The library provided by the baz virtual package
@property
def baz_libs(self):
return find_libraries("libFooBaz", root=self.baz_home, recursive=True)
return find_libraries("libFooBaz", root=self.baz_home)
Now consider another package, ``foo-app``, depending on all three:

View File

@ -1691,6 +1691,7 @@ def find(
root: Union[Path, Sequence[Path]],
files: Union[str, Sequence[str]],
recursive: bool = True,
*,
max_depth: Optional[int] = None,
) -> List[str]:
"""Finds all files matching the patterns from ``files`` starting from ``root``. This function
@ -2104,7 +2105,13 @@ def add_macro(self, macro):
self._macro_definitions.append(macro)
def find_headers(headers, root, recursive=False):
def find_headers(
headers: Union[List[str], str],
root: str,
recursive: Union[bool, str] = "heuristic",
*,
max_depth: Optional[int] = None,
) -> HeaderList:
"""Returns an iterable object containing a list of full paths to
headers if found.
@ -2120,10 +2127,11 @@ def find_headers(headers, root, recursive=False):
======= ====================================
Parameters:
headers (str or list): Header name(s) to search for
root (str): The root directory to start searching from
recursive (bool): if False search only root folder,
if True descends top-down from the root. Defaults to False.
headers: Header name(s) to search for
root: The root directory to start searching from
recursive: if False search only root folder, if True recurse from the root. Defaults to
"heuristic", which uses a non-exhaustive, faster search.
max_depth: if set, don't search below this depth. Cannot be set if recursive is False.
Returns:
HeaderList: The headers that have been found
@ -2131,10 +2139,13 @@ def find_headers(headers, root, recursive=False):
if isinstance(headers, str):
headers = [headers]
elif not isinstance(headers, collections.abc.Sequence):
message = "{0} expects a string or sequence of strings as the "
message += "first argument [got {1} instead]"
message = message.format(find_headers.__name__, type(headers))
raise TypeError(message)
raise TypeError(
f"{find_headers.__name__} expects a string or sequence of strings as the "
f"first argument [got {type(headers)} instead]"
)
if recursive is False and max_depth is not None:
raise ValueError(f"max_depth ({max_depth}) cannot be set if recursive is False")
# Construct the right suffix for the headers
suffixes = [
@ -2154,18 +2165,32 @@ def find_headers(headers, root, recursive=False):
]
# List of headers we are searching with suffixes
headers = ["{0}.{1}".format(header, suffix) for header in headers for suffix in suffixes]
headers = [f"{header}.{suffix}" for header in headers for suffix in suffixes]
return HeaderList(find(root, headers, recursive))
if isinstance(recursive, bool):
return HeaderList(find(root, headers, recursive=recursive, max_depth=max_depth))
# The heuristic here is simpler than the one for libraries: restrict search to <root>/include
# (if root isn't an include directory itself) and limit search depth so that headers are found
# not deeper than <root>/include/<subdir>/<subdir>/*.
if max_depth is None:
max_depth = 3
if os.path.basename(root).lower() != "include":
root = os.path.join(root, "include")
max_depth -= 1
return HeaderList(find(root, headers, recursive=True, max_depth=max_depth))
@system_path_filter
def find_all_headers(root):
"""Convenience function that returns the list of all headers found
in the directory passed as argument.
def find_all_headers(root: str) -> HeaderList:
"""Convenience function that returns the list of all headers found in the directory passed as
argument.
Args:
root (str): directory where to look recursively for header files
root: directory where to look recursively for header files
Returns:
List of all headers found in ``root`` and subdirectories.
@ -2323,9 +2348,15 @@ def find_system_libraries(libraries, shared=True):
def find_libraries(
libraries, root, shared=True, recursive=False, runtime=True, max_depth: Optional[int] = None
):
"""Returns an iterable of full paths to libraries found in a root dir.
libraries: Union[List[str], str],
root: str,
shared: bool = True,
recursive: Union[bool, str] = "heuristic",
runtime: bool = True,
*,
max_depth: Optional[int] = None,
) -> LibraryList:
"""Find libraries in the specified root directory.
Accepts any glob characters accepted by fnmatch:
@ -2339,18 +2370,14 @@ def find_libraries(
======= ====================================
Parameters:
libraries (str or list): Library name(s) to search for
root (str): The root directory to start searching from
shared (bool): if True searches for shared libraries,
otherwise for static. Defaults to True.
recursive (bool): if False search only root folder,
if True descends top-down from the root. Defaults to False.
max_depth (int): if set, don't search below this depth. Cannot be set
if recursive is False
runtime (bool): Windows only option, no-op elsewhere. If true,
search for runtime shared libs (.DLL), otherwise, search
for .Lib files. If shared is false, this has no meaning.
Defaults to True.
libraries: library name(s) to search for
root: the root directory to start searching from
shared: if True searches for shared libraries, otherwise for static. Defaults to True.
recursive: if False search only root folder, if True recurse from the root. Defaults to
"heuristic", which uses a non-exhaustive, faster search.
runtime: Windows only option, no-op elsewhere. If True (default), search for runtime shared
libs (.DLL), otherwise, search for .Lib files. If shared is False, this has no meaning.
max_depth: if set, don't search below this depth. Cannot be set if recursive is False.
Returns:
LibraryList: The libraries that have been found
@ -2359,10 +2386,13 @@ def find_libraries(
if isinstance(libraries, str):
libraries = [libraries]
elif not isinstance(libraries, collections.abc.Sequence):
message = "{0} expects a string or sequence of strings as the "
message += "first argument [got {1} instead]"
message = message.format(find_libraries.__name__, type(libraries))
raise TypeError(message)
raise TypeError(
f"{find_libraries.__name__} expects a string or sequence of strings as the "
f"first argument [got {type(libraries)} instead]"
)
if recursive is False and max_depth is not None:
raise ValueError(f"max_depth ({max_depth}) cannot be set if recursive is False")
if sys.platform == "win32":
static_ext = "lib"
@ -2385,33 +2415,52 @@ def find_libraries(
suffixes = [static_ext]
# List of libraries we are searching with suffixes
libraries = ["{0}.{1}".format(lib, suffix) for lib in libraries for suffix in suffixes]
libraries = [f"{lib}.{suffix}" for lib in libraries for suffix in suffixes]
if not recursive:
if max_depth:
raise ValueError(f"max_depth ({max_depth}) cannot be set if recursive is False")
# If not recursive, look for the libraries directly in root
return LibraryList(find(root, libraries, recursive=False))
if isinstance(recursive, bool):
return LibraryList(find(root, libraries, recursive=recursive, max_depth=max_depth))
# Heuristic search: a form of non-exhaustive iterative deepening, in order to return early if
# libraries are found in their usual locations. This is the default behavior for recursive
# searches.
if max_depth is None:
# this default covers search in <root>/lib/pythonX.Y/site-packages/<package>/*.
max_depth = 4
# To speedup the search for external packages configured e.g. in /usr,
# perform first non-recursive search in root/lib then in root/lib64 and
# finally search all of root recursively. The search stops when the first
# match is found.
common_lib_dirs = ["lib", "lib64"]
if sys.platform == "win32":
common_lib_dirs.extend(["bin", "Lib"])
for subdir in common_lib_dirs:
dirname = join_path(root, subdir)
if not os.path.isdir(dirname):
continue
found_libs = find(dirname, libraries, False)
if found_libs:
break
common_lib_dirs = ("lib", "lib64", "bin", "Lib")
else:
found_libs = find(root, libraries, recursive=True, max_depth=max_depth)
common_lib_dirs = ("lib", "lib64")
return LibraryList(found_libs)
if os.path.basename(root).lower() not in common_lib_dirs:
# search root and its direct library subdirectories non-recursively
non_recursive = [root, *(os.path.join(root, libdir) for libdir in common_lib_dirs)]
# avoid the expensive recursive search of the root directory
fallback_recursive = [os.path.join(root, libdir) for libdir in common_lib_dirs]
# reduce max_depth by 1 as we already joined the common library directories
max_depth -= 1
else:
# the call site already has a common library dir as root
non_recursive = [root]
fallback_recursive = [root]
found_libs = find(non_recursive, libraries, recursive=False)
if found_libs:
return LibraryList(found_libs)
# Do one more (manual) step of iterative deepening, to early exit on typical
# <root>/lib/<triplet>/ sub-directories before exhaustive, max_depth search. Slightly better
# would be to add lib/<triplet> itself to common_lib_dirs, but we are lacking information to
# determine the triplet.
if max_depth is None or max_depth > 1:
found_libs = find(fallback_recursive, libraries, max_depth=1)
if found_libs:
return LibraryList(found_libs)
# Finally fall back to exhaustive, recursive search
return LibraryList(find(fallback_recursive, libraries, recursive=True, max_depth=max_depth))
def find_all_shared_libraries(root, recursive=False, runtime=True):

View File

@ -1097,20 +1097,19 @@ def _command_default_handler(spec: "Spec"):
def _headers_default_handler(spec: "Spec"):
"""Default handler when looking for the 'headers' attribute.
Tries to search for ``*.h`` files recursively starting from
``spec.package.home.include``.
Tries to search heuristically for header files in ``spec.package.home``.
Parameters:
spec: spec that is being queried
Returns:
HeaderList: The headers in ``prefix.include``
HeaderList: The headers in ``prefix``
Raises:
NoHeadersError: If no headers are found
"""
home = getattr(spec.package, "home")
headers = fs.find_headers("*", root=home.include, recursive=True)
headers = fs.find_headers("*", root=home)
if headers:
return headers
@ -1160,7 +1159,7 @@ def _libs_default_handler(spec: "Spec"):
for shared in search_shared:
# Since we are searching for link libraries, on Windows search only for
# ".Lib" extensions by default as those represent import libraries for implicit links.
libs = fs.find_libraries(name, home, shared=shared, recursive=True, runtime=False)
libs = fs.find_libraries(name, home, shared=shared, runtime=False)
if libs:
return libs

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import fnmatch
import os.path
import pathlib
import sys
import pytest
@ -242,7 +242,7 @@ def test_add(self, header_list):
#: Directory where the data for the test below is stored
search_dir = os.path.join(spack.paths.test_path, "data", "directory_search")
search_dir = pathlib.Path(spack.paths.test_path) / "data" / "directory_search"
@pytest.mark.parametrize(
@ -257,7 +257,7 @@ def test_add(self, header_list):
],
)
def test_library_type_search(lib_list, kwargs):
results = find_libraries(lib_list, search_dir, **kwargs)
results = find_libraries(lib_list, str(search_dir), **kwargs)
assert len(results) != 0
for result in results:
lib_type_ext = plat_shared_ext
@ -293,13 +293,17 @@ def test_library_type_search(lib_list, kwargs):
(find_headers, ["a", "c"], search_dir, {"recursive": True}),
(find_headers, ["c", "b", "a"], search_dir, {"recursive": True}),
(find_headers, ["a", "c"], search_dir, {"recursive": True}),
(find_libraries, ["liba", "libd"], os.path.join(search_dir, "b"), {"recursive": False}),
(find_headers, ["b", "d"], os.path.join(search_dir, "b"), {"recursive": False}),
(find_libraries, ["liba", "libd"], search_dir / "lib" / "a", {"recursive": False}),
(find_headers, ["a", "d"], search_dir / "include" / "a", {"recursive": False}),
],
)
def test_searching_order(search_fn, search_list, root, kwargs):
"""Tests whether when multiple libraries or headers are searched for, like [a, b], the found
file list adheres to the same ordering: [a matches..., b matches...], which is relevant in case
of dependencies across static libraries, and we want to ensure they are passed in the correct
order to the linker."""
# Test search
result = search_fn(search_list, root, **kwargs)
result = search_fn(search_list, str(root), **kwargs)
# The tests are set-up so that something is always found
assert len(result) != 0

View File

@ -386,7 +386,6 @@ def blas_libs(self):
[libname, "libamath", "libastring"],
root=armpl_prefix,
shared=self.spec.satisfies("+shared"),
recursive=True,
)
armpl_libs += find_system_libraries(["libm"])
@ -416,7 +415,7 @@ def headers(self):
incdir = join_path(armpl_dir, suffix)
hlist = find_all_headers(incdir)
hlist = find_headers("*", incdir)
hlist.directories = [incdir]
return hlist

View File

@ -350,7 +350,7 @@ def libs(self):
libs_to_seek.add("libadios2_fortran")
return find_libraries(
list(libs_to_seek), root=self.spec.prefix, shared=("+shared" in spec), recursive=True
list(libs_to_seek), root=self.spec.prefix, shared=("+shared" in spec)
)
def setup_run_environment(self, env):

View File

@ -119,5 +119,4 @@ def libs(self):
["libblis"] if self.spec.satisfies("threads=none") else ["libblis-mt"],
root=self.prefix,
shared=self.spec.satisfies("libs=shared"),
recursive=True,
)

View File

@ -110,16 +110,12 @@ class Amdlibflame(CMakePackage, LibflameBase):
@property
def lapack_libs(self):
"""find lapack_libs function"""
return find_libraries(
"libflame", root=self.prefix, shared="+shared" in self.spec, recursive=True
)
return find_libraries("libflame", root=self.prefix, shared="+shared" in self.spec)
@property
def libs(self):
"""find libflame libs function"""
return find_libraries(
"libflame", root=self.prefix, shared="+shared" in self.spec, recursive=True
)
return find_libraries("libflame", root=self.prefix, shared="+shared" in self.spec)
def flag_handler(self, name, flags):
if name == "cflags":

View File

@ -67,7 +67,7 @@ class AoclLibmem(CMakePackage):
def libs(self):
"""find libmem libs function"""
shared = "+shared" in self.spec
return find_libraries("libaocl-libmem", root=self.prefix, recursive=True, shared=shared)
return find_libraries("libaocl-libmem", root=self.prefix, shared=shared)
def cmake_args(self):
"""Runs ``cmake`` in the build directory"""

View File

@ -77,9 +77,7 @@ class AoclSparse(CMakePackage):
@property
def libs(self):
"""find libaoclsparse libs function"""
return find_libraries(
"libaoclsparse", root=self.prefix, shared="+shared" in self.spec, recursive=True
)
return find_libraries("libaoclsparse", root=self.prefix, shared="+shared" in self.spec)
@property
def build_directory(self):

View File

@ -57,7 +57,7 @@ class AoclUtils(CMakePackage):
def libs(self):
"""find aocl-utils libs function"""
shared = "+shared" in self.spec
return find_libraries("libaoclutils", root=self.prefix, recursive=True, shared=shared)
return find_libraries("libaoclutils", root=self.prefix, shared=shared)
def cmake_args(self):
args = [

View File

@ -66,13 +66,9 @@ def libs(self):
it will link dynamically to `/usr/lib/system/libunwind.dylib`.
"""
libs = find_libraries("libSystem", self.prefix.lib, shared=True, recursive=False)
if libs:
return libs
return None
return find_libraries("libSystem", self.prefix.lib, shared=True, recursive=False)
@property
def headers(self):
"""Export the Apple libunwind header"""
hdrs = HeaderList(find(self.prefix.include, "libunwind.h", recursive=False))
return hdrs or None
return HeaderList(find(self.prefix.include, "libunwind.h", recursive=False))

View File

@ -40,9 +40,7 @@ class AprUtil(AutotoolsPackage):
@property
def libs(self):
return find_libraries(
[f"libaprutil-{self.version.up_to(1)}"], root=self.prefix, recursive=True
)
return find_libraries([f"libaprutil-{self.version.up_to(1)}"], root=self.prefix)
def configure_args(self):
spec = self.spec

View File

@ -33,6 +33,4 @@ class Apr(AutotoolsPackage):
@property
def libs(self):
return find_libraries(
[f"libapr-{self.version.up_to(1)}"], root=self.prefix, recursive=True
)
return find_libraries([f"libapr-{self.version.up_to(1)}"], root=self.prefix)

View File

@ -133,14 +133,13 @@ def libs(self):
["libarm_compute", "libarm_compute_core", "libarm_compute_graph"],
root=self.spec.prefix,
shared=True,
recursive=True,
)
return acl_libs
@property
def headers(self):
incdir = join_path(self.spec.prefix, "include")
hlist = find_all_headers(incdir)
hlist = find_headers("*", incdir)
hlist.directories = [incdir]
return hlist

View File

@ -457,7 +457,6 @@ def blas_libs(self):
[libname, "libamath", "libastring"],
root=armpl_prefix,
shared=self.spec.satisfies("+shared"),
recursive=True,
)
armpl_libs += find_system_libraries(["libm"])
@ -487,7 +486,7 @@ def headers(self):
incdir = join_path(armpl_dir, suffix)
hlist = find_all_headers(incdir)
hlist = find_headers("*", incdir)
hlist.directories = [incdir]
return hlist

View File

@ -112,7 +112,7 @@ def libs(self):
if self.spec.satisfies("+mpi"):
libraries = ["libparpack"] + libraries
return find_libraries(libraries, root=self.prefix, shared=True, recursive=True)
return find_libraries(libraries, root=self.prefix, shared=True)
class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):

View File

@ -67,7 +67,7 @@ def libs(self):
if not query_parameters or "unified" in query_parameters:
libraries.append("libaf")
return find_libraries(libraries, root=self.prefix, recursive=True)
return find_libraries(libraries, root=self.prefix)
def cmake_args(self):
args = []

View File

@ -152,7 +152,7 @@ def libs(self):
)
to_find = ["liblapack"] + interfaces + ["libatlas"]
shared = False
return find_libraries(to_find, root=self.prefix, shared=shared, recursive=True)
return find_libraries(to_find, root=self.prefix, shared=shared)
def install_test(self):
source_file = join_path(os.path.dirname(self.module.__file__), "test_cblas_dgemm.c")

View File

@ -99,4 +99,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libatlab-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libatlab-*", root=self.prefix, shared=shared)

View File

@ -120,4 +120,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libCheSS-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libCheSS-*", root=self.prefix, shared=shared)

View File

@ -134,4 +134,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libbigdft-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libbigdft-*", root=self.prefix, shared=shared)

View File

@ -105,4 +105,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libfutile-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libfutile-*", root=self.prefix, shared=shared)

View File

@ -87,4 +87,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libabinit", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libabinit", root=self.prefix, shared=shared)

View File

@ -90,4 +90,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libbigdft-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libbigdft-*", root=self.prefix, shared=shared)

View File

@ -108,4 +108,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libPSolver-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libPSolver-*", root=self.prefix, shared=shared)

View File

@ -105,4 +105,4 @@ def configure_args(self):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libspred-*", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libspred-*", root=self.prefix, shared=shared)

View File

@ -172,7 +172,7 @@ def libs(self):
libnames += ["monitor"]
libraries = ["libboost_*%s*" % lib for lib in libnames]
return find_libraries(libraries, root=self.prefix, shared=shared, recursive=True)
return find_libraries(libraries, root=self.prefix, shared=shared)
variant(
"context-impl",

View File

@ -23,6 +23,4 @@ class Brunsli(CMakePackage):
@property
def libs(self):
return find_libraries(
["libbrunslidec-c", "libbrunslienc-c"], root=self.prefix, recursive=True
)
return find_libraries(["libbrunslidec-c", "libbrunslienc-c"], root=self.prefix)

View File

@ -108,7 +108,7 @@ def _setup_bufr_environment(self, env, suffix):
shared = True if "+shared" in self.spec else False
# Bufr has _DA (dynamic allocation) libs in versions <= 11.5.0
append = "" if self.spec.satisfies("@11.5.0:") else "_DA"
lib = find_libraries(libname + append, root=self.prefix, shared=shared, recursive=True)
lib = find_libraries(libname + append, root=self.prefix, shared=shared)
lib_envname = "BUFR_LIB{0}".format(suffix) + append
inc_envname = "BUFR_INC{0}".format(suffix) + append
include_dir = "{0}_{1}".format(self.prefix.include.bufr, suffix)

View File

@ -61,7 +61,7 @@ def determine_version(cls, exe):
@property
def libs(self):
shared = "+shared" in self.spec
return find_libraries("libbz2", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libbz2", root=self.prefix, shared=shared)
def flag_handler(self, name, flags):
if name == "cflags":

View File

@ -30,4 +30,4 @@ def url_for_version(self, version):
@property
def libs(self):
return find_libraries(["libcares"], root=self.prefix, recursive=True)
return find_libraries(["libcares"], root=self.prefix)

View File

@ -49,7 +49,7 @@ class CBlosc(CMakePackage):
@property
def libs(self):
return find_libraries("libblosc", root=self.prefix, recursive=True)
return find_libraries("libblosc", root=self.prefix)
def cmake_args(self):
args = []

View File

@ -71,4 +71,4 @@ def libs(self):
libraries.append("libfftw3" + sfx)
return find_libraries(libraries, root=self.prefix, recursive=True)
return find_libraries(libraries, root=self.prefix)

View File

@ -109,7 +109,7 @@ def install(self, spec, prefix):
@property
def headers(self):
hdrs = find_headers("mpi", self.prefix.include, recursive=True)
hdrs = find_headers("mpi", self.prefix.include)
hdrs.directories = os.path.dirname(hdrs[0])
return hdrs
@ -128,7 +128,4 @@ def libs(self):
if "f90" in query_parameters:
libraries.extend(["libmpif90", "libmpichf90"])
libs = find_libraries(libraries, root=self.prefix.lib, recursive=True)
libs += find_libraries(libraries, root=self.prefix.lib64, recursive=True)
return libs
return find_libraries(libraries, root=self.prefix)

View File

@ -20,8 +20,8 @@ class CrayPmi(Package):
@property
def headers(self):
return find_headers("pmi", self.prefix.include, recursive=True)
return find_headers("pmi", self.prefix)
@property
def libs(self):
return find_libraries(["libpmi"], root=self.prefix, recursive=True)
return find_libraries(["libpmi"], root=self.prefix)

View File

@ -795,7 +795,7 @@ def install(self, spec, prefix):
@property
def libs(self):
libs = find_libraries("libcudart", root=self.prefix, shared=True, recursive=True)
libs = find_libraries("libcudart", root=self.prefix, shared=True)
filtered_libs = []
# CUDA 10.0 provides Compatability libraries for running newer versions

View File

@ -149,7 +149,7 @@ def libs(self):
# We need to override libs here, because we don't build a libdd4hep so
# the default discovery fails. All libraries that are built by DD4hep
# start with libDD
return find_libraries("libDD*", root=self.prefix, shared=True, recursive=True)
return find_libraries("libDD*", root=self.prefix, shared=True)
def cmake_args(self):
spec = self.spec

View File

@ -233,7 +233,7 @@ class Dihydrogen(CachedCMakePackage, CudaPackage, ROCmPackage):
@property
def libs(self):
shared = True if "+shared" in self.spec else False
return find_libraries("libH2Core", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libH2Core", root=self.prefix, shared=shared)
def cmake_args(self):
args = []

View File

@ -35,7 +35,7 @@ def libs(self):
key = tuple(query_parameters)
libraries = query2libraries[key]
return find_libraries(libraries, root=self.prefix, shared=True, recursive=True)
return find_libraries(libraries, root=self.prefix, shared=True)
def setup_build_environment(self, env):
env.set("DISLIN", self.prefix)

View File

@ -28,7 +28,7 @@ class Dsfmt(MakefilePackage):
@property
def libs(self):
return find_libraries("libdSFMT", root=self.prefix, recursive=True)
return find_libraries("libdSFMT", root=self.prefix)
def build(self, spec, prefix):
make("build-library", "CC=cc")

View File

@ -168,13 +168,13 @@ def cmake_args(self):
# Elf -- the directory containing libelf.h.
elf = spec["elf"].prefix
elf_include = os.path.dirname(find_headers("libelf", elf.include, recursive=True)[0])
elf_include = os.path.dirname(find_headers("libelf", elf.include)[0])
# Dwarf -- the directory containing elfutils/libdw.h or
# libdwarf.h, and the path to libdw.so or libdwarf.so.
if spec.satisfies("@10.0.0:"):
dwarf_include = elf.include
dwarf_lib = find_libraries("libdw", elf, recursive=True)
dwarf_lib = find_libraries("libdw", elf)
else:
dwarf_include = spec["libdwarf"].prefix.include
dwarf_lib = spec["libdwarf"].libs

View File

@ -295,7 +295,7 @@ def libs(self):
if return_memfs:
libraries.append("libeccodes_memfs")
libs = find_libraries(libraries, root=self.prefix, shared=shared, recursive=True)
libs = find_libraries(libraries, root=self.prefix, shared=shared)
if libs and len(libs) == len(libraries):
return libs

View File

@ -78,15 +78,15 @@ def libs(self):
@property
def egl_headers(self):
header_name = "GL/gl"
gl_header = find_headers(header_name, root=self.prefix, recursive=True)
gl_header = find_headers(header_name, root=self.prefix)
header_name = "EGL/egl"
egl_header = find_headers(header_name, root=self.prefix, recursive=True)
egl_header = find_headers(header_name, root=self.prefix)
return gl_header + egl_header
@property
def egl_libs(self):
lib_name = "libGL"
gl_lib = find_libraries(lib_name, root=self.prefix, recursive=True)
gl_lib = find_libraries(lib_name, root=self.prefix)
lib_name = "libEGL"
egl_lib = find_libraries(lib_name, root=self.prefix, recursive=True)
egl_lib = find_libraries(lib_name, root=self.prefix)
return gl_lib + egl_lib

View File

@ -84,6 +84,6 @@ def cmake_args(self):
@property
def headers(self):
headers = find_all_headers(self.prefix.include)
headers = find_headers("*", self.prefix)
headers.directories = [self.prefix.include.eigen3]
return headers

View File

@ -98,7 +98,7 @@ class Elemental(CMakePackage):
@property
def libs(self):
shared = True if "+shared" in self.spec else False
return find_libraries("libEl", root=self.prefix, shared=shared, recursive=True)
return find_libraries("libEl", root=self.prefix, shared=shared)
def cmake_args(self):
spec = self.spec
@ -123,7 +123,7 @@ def cmake_args(self):
ifort = env["SPACK_F77"]
intel_bin = os.path.dirname(ifort)
intel_root = os.path.dirname(intel_bin)
libfortran = find_libraries("libifcoremt", root=intel_root, recursive=True)
libfortran = find_libraries("libifcoremt", root=intel_root)
elif self.spec.satisfies("%gcc"):
# see <stage_folder>/debian/rules as an example:
mpif77 = Executable(spec["mpi"].mpif77)
@ -134,7 +134,7 @@ def cmake_args(self):
xl_fort = env["SPACK_F77"]
xl_bin = os.path.dirname(xl_fort)
xl_root = os.path.dirname(xl_bin)
libfortran = find_libraries("libxlf90_r", root=xl_root, recursive=True)
libfortran = find_libraries("libxlf90_r", root=xl_root)
else:
libfortran = None

View File

@ -166,4 +166,4 @@ def install_elfh(self):
# Provide location of libelf.so to match libelf.
@property
def libs(self):
return find_libraries("libelf", self.prefix, recursive=True)
return find_libraries("libelf", self.prefix)

View File

@ -113,7 +113,7 @@ def url_for_version(self, version):
@property
def libs(self):
libname = "libelpa_openmp" if "+openmp" in self.spec else "libelpa"
return find_libraries(libname, root=self.prefix, shared=True, recursive=True)
return find_libraries(libname, root=self.prefix, shared=True)
@property
def headers(self):
@ -130,7 +130,7 @@ def headers(self):
"elpa{suffix}-{version}".format(suffix=suffix, version=elpa_version),
)
hlist = find_all_headers(incdir)
hlist = find_headers("*", incdir)
hlist.directories = [incdir]
return hlist

View File

@ -58,7 +58,7 @@ def libs(self):
if self.version >= Version("0.0.32"): # TODO actual lower bound
libs.append("LLDEnzyme-{0}".format(ver))
return find_libraries(libs, root=self.prefix, recursive=True)
return find_libraries(libs, root=self.prefix)
def setup_dependent_build_environment(self, env, dependent_spec):
# Get the LLVMEnzyme and ClangEnzyme lib paths

View File

@ -142,7 +142,7 @@ def configure_args(self):
)
if spec.satisfies("+cupti"):
cupti_h = find_headers("cupti", spec["cuda"].prefix, recursive=True)
cupti_h = find_headers("cupti", spec["cuda"].prefix)
cupti_dir = os.path.dirname(os.path.dirname(cupti_h[0]))
args += ["--with-cupti=%s" % cupti_dir] if "+cupti" in spec else ["--without-cupti"]

View File

@ -71,7 +71,7 @@ class Fdb(CMakePackage):
@property
def libs(self):
return find_libraries("libfdb5", root=self.prefix, shared=True, recursive=True)
return find_libraries("libfdb5", root=self.prefix, shared=True)
def cmake_args(self):
enable_build_tools = "+tools" in self.spec

View File

@ -171,11 +171,11 @@ class Ffmpeg(AutotoolsPackage):
@property
def libs(self):
return find_libraries("*", self.prefix, recursive=True)
return find_libraries("*", self.prefix)
@property
def headers(self):
headers = find_all_headers(self.prefix.include)
headers = find_headers("*", self.prefix)
headers.directories = [self.prefix.include]
return headers

View File

@ -62,7 +62,7 @@ def libs(self):
libraries.append("libfftw3" + sfx)
return find_libraries(libraries, root=self.prefix, recursive=True)
return find_libraries(libraries, root=self.prefix)
def flag_handler(self, name, flags):
if name == "cflags":

View File

@ -75,4 +75,4 @@ def cmake_args(self):
@property
def libs(self):
return find_libraries(["libglut"], root=self.prefix, recursive=True)
return find_libraries(["libglut"], root=self.prefix)

View File

@ -81,7 +81,7 @@ def url_for_version(self, version):
@property
def headers(self):
headers = find_headers("*", self.prefix.include, recursive=True)
headers = find_headers("*", self.prefix.include)
headers.directories = [self.prefix.include.freetype2]
return headers

View File

@ -29,7 +29,7 @@ def install(self, spec, prefix):
@property
def headers(self):
hdrs = find_headers("mpi", self.prefix.include, recursive=True)
hdrs = find_headers("mpi", self.prefix.include)
hdrs.directories = os.path.dirname(hdrs[0])
return hdrs or None
@ -41,7 +41,7 @@ def libs(self):
if "cxx" in query_parameters:
libraries = ["libmpi_cxx"] + libraries
return find_libraries(libraries, root=self.prefix, shared=True, recursive=True)
return find_libraries(libraries, root=self.prefix, shared=True)
def setup_dependent_package(self, module, dependent_spec):
if self.spec.satisfies("%gcc"):

View File

@ -131,5 +131,5 @@ def setup_dependent_build_environment(self, env, dependent_spec):
@property
def headers(self):
path = join_path(self.spec.prefix, "clang-comp")
headers = find_headers("cssl", path, recursive=True)
headers = find_headers("cssl", path)
return headers

View File

@ -89,7 +89,7 @@ def setup_run_environment(self, env):
shared = False
else:
shared = self.spec.satisfies("libs=shared")
lib = find_libraries("libg2c", root=self.prefix, shared=shared, recursive=True)
lib = find_libraries("libg2c", root=self.prefix, shared=shared)
env.set("G2C_LIB", lib[0])
env.set("G2C_INC", join_path(self.prefix, "include"))

View File

@ -33,7 +33,7 @@ def cmake_args(self):
return args
def setup_run_environment(self, env):
lib = find_libraries("libgfsio", root=self.prefix, shared=False, recursive=True)
lib = find_libraries("libgfsio", root=self.prefix, shared=False)
# Only one library version, but still need to set _4 to make NCO happy
for suffix in ("4", ""):
env.set("GFSIO_LIB" + suffix, lib[0])

View File

@ -205,7 +205,7 @@ def patch(self):
@property
def libs(self):
return find_libraries(["libglib*"], root=self.prefix, recursive=True)
return find_libraries(["libglib*"], root=self.prefix)
class BaseBuilder(metaclass=spack.builder.PhaseCallbacksMeta):

View File

@ -30,7 +30,7 @@ def libs(self):
@property
def gl_headers(self):
return find_headers("GL/gl", root=self.gl_home, recursive=True)
return find_headers("GL/gl", root=self.gl_home)
@property
def gl_libs(self):

View File

@ -98,6 +98,6 @@ def configure_args(self):
@property
def headers(self):
headers = find_all_headers(self.prefix.include)
headers = find_headers("*", self.prefix)
headers.directories = [self.prefix.include]
return headers

View File

@ -95,7 +95,7 @@ class Halide(CMakePackage, PythonExtension):
@property
def libs(self):
return find_libraries("libHalide", root=self.prefix, recursive=True)
return find_libraries("libHalide", root=self.prefix)
def cmake_args(self):
# See https://github.com/halide/Halide/blob/main/README_cmake.md#building-halide-with-cmake

View File

@ -123,7 +123,7 @@ def libs(self):
else:
shared = self.spec.satisfies("+shared")
libs = find_libraries(libraries, root=self.prefix, shared=shared, recursive=True)
libs = find_libraries(libraries, root=self.prefix, shared=shared)
if not libs:
msg = "Unable to recursively locate {0} {1} libraries in {2}"

View File

@ -433,7 +433,7 @@ def libs(self):
key = tuple(sorted(query_parameters))
libraries = query2libraries[key]
return find_libraries(libraries, root=self.prefix, shared=shared, recursive=True)
return find_libraries(libraries, root=self.prefix, shared=shared)
@classmethod
def determine_version(cls, exe):

View File

@ -60,7 +60,7 @@ class Hepmc3(CMakePackage):
@property
def libs(self):
return find_libraries(["libHepMC3", "libHepMC3Search"], root=self.prefix, recursive=True)
return find_libraries(["libHepMC3", "libHepMC3Search"], root=self.prefix)
def cmake_args(self):
spec = self.spec

View File

@ -168,7 +168,7 @@ def adjust_core_config(config):
rpaths = set()
if self.spec.satisfies("~rocm"):
so_paths = filesystem.find_libraries(
"libc++", self.spec["llvm"].prefix, shared=True, recursive=True
"libc++", self.spec["llvm"].prefix, shared=True
)
if len(so_paths) != 1:
raise InstallError(
@ -178,7 +178,7 @@ def adjust_core_config(config):
)
rpaths.add(path.dirname(so_paths[0]))
so_paths = filesystem.find_libraries(
"libc++abi", self.spec["llvm"].prefix, shared=True, recursive=True
"libc++abi", self.spec["llvm"].prefix, shared=True
)
if len(so_paths) != 1:
raise InstallError(

View File

@ -121,9 +121,7 @@ def cmake_args(self):
# hsa-rocr-dev wants the directory containing the header files, but
# libelf adds an extra path (include/libelf) compared to elfutils
libelf_include = os.path.dirname(
find_headers("libelf", spec["elf"].prefix.include, recursive=True)[0]
)
libelf_include = os.path.dirname(find_headers("libelf", spec["elf"].prefix.include)[0])
args = [
self.define("LIBELF_INCLUDE_DIRS", libelf_include),

View File

@ -73,7 +73,7 @@ class Htslib(AutotoolsPackage):
@property
def libs(self):
return find_libraries("libhts", root=self.prefix, recursive=True)
return find_libraries("libhts", root=self.prefix)
# v1.2 uses the automagically assembled tarball from .../archive/...
# everything else uses the tarballs uploaded to the release

View File

@ -156,7 +156,7 @@ def url_for_version(self, version):
@property
def libs(self):
libs = find_libraries("libhwloc", root=self.prefix, shared=True, recursive=True)
libs = find_libraries("libhwloc", root=self.prefix, shared=True)
return LibraryList(libs)
def configure_args(self):

Some files were not shown because too many files have changed in this diff Show More