diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2022-06-29 11:55:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-29 11:55:24 -0700 |
commit | 93c16f1ee377606fa232ceb3141cc1be32dbfeba (patch) | |
tree | 1e1fa83c93de706f401e61df21a8754cc45d72e7 /lib | |
parent | 7bacde16e4516473eb562f8317e3ef70b3d3aac5 (diff) | |
download | spack-93c16f1ee377606fa232ceb3141cc1be32dbfeba.tar.gz spack-93c16f1ee377606fa232ceb3141cc1be32dbfeba.tar.bz2 spack-93c16f1ee377606fa232ceb3141cc1be32dbfeba.tar.xz spack-93c16f1ee377606fa232ceb3141cc1be32dbfeba.zip |
PythonPackage: add default libs/headers attributes (#28527)
* PythonPackage: add default libs/headers attributes
* Style fix
* libs and headers should be properties
* Check both platlib and include
* Fix variable reference
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/python.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index d72b9c5a8d..3eec9d5d3b 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -12,6 +12,8 @@ import llnl.util.tty as tty from llnl.util.filesystem import ( filter_file, find, + find_all_headers, + find_libraries, is_nonsymlink_exe_with_shebang, path_contains_subdirectory, same_path, @@ -20,6 +22,7 @@ from llnl.util.filesystem import ( from llnl.util.lang import match_predicate from spack.directives import depends_on, extends +from spack.error import NoHeadersError, NoLibrariesError from spack.package_base import PackageBase, run_after @@ -178,6 +181,37 @@ class PythonPackage(PackageBase): with working_dir(self.build_directory): pip(*args) + @property + def headers(self): + """Discover header files in platlib.""" + + # Headers may be in either location + include = inspect.getmodule(self).include + platlib = inspect.getmodule(self).platlib + headers = find_all_headers(include) + find_all_headers(platlib) + + if headers: + return headers + + msg = 'Unable to locate {} headers in {} or {}' + raise NoHeadersError(msg.format(self.spec.name, include, platlib)) + + @property + def libs(self): + """Discover libraries in platlib.""" + + # Remove py- prefix in package name + library = 'lib' + self.spec.name[3:].replace('-', '?') + root = inspect.getmodule(self).platlib + + for shared in [True, False]: + libs = find_libraries(library, root, shared=shared, recursive=True) + if libs: + return libs + + msg = 'Unable to recursively locate {} libraries in {}' + raise NoLibrariesError(msg.format(self.spec.name, root)) + # Testing def test(self): |