Skip to content

Commit f35ae5e

Browse files
committed
Remove extra indent by checking for missing root first
1 parent 9395187 commit f35ae5e

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

easybuild/tools/modules.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,52 +1712,52 @@ def get_software_libdir(name, only_one=True, fs=None, full_path=False):
17121712
"""
17131713
lib_subdirs = ['lib', 'lib64']
17141714
root = get_software_root(name)
1715+
if not root:
1716+
# return None if software package root could not be determined
1717+
return None
1718+
17151719
found_subdirs = []
1716-
if root:
1717-
for lib_subdir in lib_subdirs:
1718-
lib_dir_path = os.path.join(root, lib_subdir)
1719-
if os.path.exists(lib_dir_path):
1720-
# take into account that lib64 could be a symlink to lib (or vice versa)
1721-
# see https://github.com/easybuilders/easybuild-framework/issues/3139
1722-
if any(os.path.samefile(lib_dir_path, os.path.join(root, x)) for x in found_subdirs):
1723-
_log.debug("%s is the same as one of the other paths, so skipping it", lib_dir_path)
1724-
1725-
elif fs is None or any(os.path.exists(os.path.join(lib_dir_path, f)) for f in fs):
1726-
_log.debug("Retaining library subdir '%s' (found at %s)", lib_subdir, lib_dir_path)
1727-
found_subdirs.append(lib_subdir)
1728-
1729-
elif build_option('extended_dry_run'):
1720+
for lib_subdir in lib_subdirs:
1721+
lib_dir_path = os.path.join(root, lib_subdir)
1722+
if os.path.exists(lib_dir_path):
1723+
# take into account that lib64 could be a symlink to lib (or vice versa)
1724+
# see https://github.com/easybuilders/easybuild-framework/issues/3139
1725+
if any(os.path.samefile(lib_dir_path, os.path.join(root, x)) for x in found_subdirs):
1726+
_log.debug("%s is the same as one of the other paths, so skipping it", lib_dir_path)
1727+
1728+
elif fs is None or any(os.path.exists(os.path.join(lib_dir_path, f)) for f in fs):
1729+
_log.debug("Retaining library subdir '%s' (found at %s)", lib_subdir, lib_dir_path)
17301730
found_subdirs.append(lib_subdir)
1731-
break
17321731

1733-
# if no library subdir was found, return None
1734-
if not found_subdirs:
1735-
return None
1736-
if full_path:
1737-
res = [os.path.join(root, subdir) for subdir in found_subdirs]
1738-
else:
1739-
res = found_subdirs
1740-
if only_one:
1741-
if len(res) == 1:
1742-
res = res[0]
1743-
else:
1744-
if fs is None and len(res) == 2:
1745-
# if both lib and lib64 were found, check if only one (exactly) has libraries;
1746-
# this is needed for software with library archives in lib64 but other files/directories in lib
1747-
lib_glob = ['*.%s' % ext for ext in ['a', get_shared_lib_ext()]]
1748-
has_libs = [any(glob.glob(os.path.join(root, subdir, f)) for f in lib_glob)
1749-
for subdir in found_subdirs]
1750-
if has_libs[0] and not has_libs[1]:
1751-
return res[0]
1752-
if has_libs[1] and not has_libs[0]:
1753-
return res[1]
1754-
1755-
raise EasyBuildError("Multiple library subdirectories found for %s in %s: %s",
1756-
name, root, ', '.join(found_subdirs))
1757-
return res
1758-
else:
1759-
# return None if software package root could not be determined
1732+
elif build_option('extended_dry_run'):
1733+
found_subdirs.append(lib_subdir)
1734+
break
1735+
1736+
# if no library subdir was found, return None
1737+
if not found_subdirs:
17601738
return None
1739+
if full_path:
1740+
res = [os.path.join(root, subdir) for subdir in found_subdirs]
1741+
else:
1742+
res = found_subdirs
1743+
if only_one:
1744+
if len(res) == 1:
1745+
res = res[0]
1746+
else:
1747+
if fs is None and len(res) == 2:
1748+
# if both lib and lib64 were found, check if only one (exactly) has libraries;
1749+
# this is needed for software with library archives in lib64 but other files/directories in lib
1750+
lib_glob = ['*.%s' % ext for ext in ['a', get_shared_lib_ext()]]
1751+
has_libs = [any(glob.glob(os.path.join(root, subdir, f)) for f in lib_glob)
1752+
for subdir in found_subdirs]
1753+
if has_libs[0] and not has_libs[1]:
1754+
return res[0]
1755+
if has_libs[1] and not has_libs[0]:
1756+
return res[1]
1757+
1758+
raise EasyBuildError("Multiple library subdirectories found for %s in %s: %s",
1759+
name, root, ', '.join(found_subdirs))
1760+
return res
17611761

17621762

17631763
def get_software_version_env_var_name(name):

0 commit comments

Comments
 (0)