-
Notifications
You must be signed in to change notification settings - Fork 220
generic sanity-checking of libraries #1424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
403f0c8
a17eb36
ac06c32
e17539d
cbdaa2d
fb22cd4
c9d153e
6ee88ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1546,6 +1546,10 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, extension=F | |
| - if *any* of the files/subdirectories in the installation directory listed | ||
| in sanity_check_paths are non-existent (or empty), the sanity check fails | ||
| """ | ||
| # constants for library checking (TODO: should probably be defined somewhere else/configurab;e) | ||
| LIB_DIRS = ['lib', 'lib64'] | ||
| LIB_SUFFIXES = {'static': ['.a'], 'shared': ['.so', '.dyn']} | ||
|
|
||
| # supported/required keys in for sanity check paths, along with function used to check the paths | ||
| path_keys_and_check = { | ||
| 'files': lambda fp: os.path.exists(fp), # files must exist | ||
|
|
@@ -1566,6 +1570,24 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, extension=F | |
| else: | ||
| self.log.info("Using specified sanity check paths: %s" % paths) | ||
|
|
||
| # transform specified libs into simple file paths | ||
| if 'libs' in paths.keys(): | ||
| for lib in paths['libs']: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| if 'name' in lib.keys() and 'kind' in lib.keys(): | ||
| if lib['kind'] in LIB_SUFFIXES.keys(): | ||
| # TODO: also check possible library version numbers (e.g. libawesome.so.3.0.1) | ||
| libpaths = () | ||
| for dir in LIB_DIRS: | ||
| for suffix in LIB_SUFFIXES[lib['kind']]: | ||
| libpaths += (os.path.join(dir, lib['name'] + suffix), ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use a list for |
||
| paths['files'] += [libpaths] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use: paths['files'].append(tuple(libpaths)) |
||
| else: | ||
| raise EasyBuildError("Library kind must either be static or shared.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't hardcode the available keys in the message, use raise EasyBuildError("Unknown kind of library, only known kinds are: %s" % ' '.join(LIB_SUFFIXES.keys())) |
||
| else: | ||
| raise EasyBuildError("Libraries are specified via 'name' and 'kind'.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/are/must be/ |
||
| # remove the libs | ||
| del paths['libs'] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this need to be removed?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise the following exception will be thrown: if not ks == req_keys or sum(valnottypes) > 0 or sum(lenvals) == 0:
raise EasyBuildError("Incorrect format for sanity_check_paths (should (only) have %s keys, "
"values should be lists (at least one non-empty)).", ','.join(req_keys))This might be circumvented by implementing the library checks as a lambda in |
||
|
|
||
| # check sanity check paths | ||
| ks = sorted(paths.keys()) | ||
| valnottypes = [not isinstance(x, list) for x in paths.values()] | ||
|
|
@@ -1585,7 +1607,7 @@ def sanity_check_step(self, custom_paths=None, custom_commands=None, extension=F | |
| found = False | ||
| for name in xs: | ||
| path = os.path.join(self.installdir, name) | ||
| if os.path.exists(path): | ||
| if check_fn(path): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is indeed a bug, this fix is also included in #1388 (which doesn't mean it shouldn't be included here) maybe we should make this a separate PR though, to make the bug fix stand out; it may have some fallout, i.e. causing sanity checks to fail on empty directories where they didn't before (they should have though)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even worse, this check will now pass on directories that are actually files this distinction can be important, for example if you want to make sure that a Python package is installed as a zipped egg, i.e., that the so, we really need a separate PR for this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #1436 |
||
| self.log.debug("Sanity check: found %s %s in %s" % (key[:-1], name, self.installdir)) | ||
| found = True | ||
| break | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constant should be defined at the top of this file, below imports
rather than hardcoding
.soor.dyn, useget_shared_lib_ext()fromeasybuild.tools.systemtoolsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. I was looking for such a method but couldn't find it. Thanks.
Edit: There is no such method for static libraries, right?