Skip to content

Commit

Permalink
Remove extra indent by checking for missing root first
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Dec 4, 2024
1 parent 9395187 commit f35ae5e
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,52 +1712,52 @@ def get_software_libdir(name, only_one=True, fs=None, full_path=False):
"""
lib_subdirs = ['lib', 'lib64']
root = get_software_root(name)
if not root:
# return None if software package root could not be determined
return None

found_subdirs = []
if root:
for lib_subdir in lib_subdirs:
lib_dir_path = os.path.join(root, lib_subdir)
if os.path.exists(lib_dir_path):
# take into account that lib64 could be a symlink to lib (or vice versa)
# see https://github.com/easybuilders/easybuild-framework/issues/3139
if any(os.path.samefile(lib_dir_path, os.path.join(root, x)) for x in found_subdirs):
_log.debug("%s is the same as one of the other paths, so skipping it", lib_dir_path)

elif fs is None or any(os.path.exists(os.path.join(lib_dir_path, f)) for f in fs):
_log.debug("Retaining library subdir '%s' (found at %s)", lib_subdir, lib_dir_path)
found_subdirs.append(lib_subdir)

elif build_option('extended_dry_run'):
for lib_subdir in lib_subdirs:
lib_dir_path = os.path.join(root, lib_subdir)
if os.path.exists(lib_dir_path):
# take into account that lib64 could be a symlink to lib (or vice versa)
# see https://github.com/easybuilders/easybuild-framework/issues/3139
if any(os.path.samefile(lib_dir_path, os.path.join(root, x)) for x in found_subdirs):
_log.debug("%s is the same as one of the other paths, so skipping it", lib_dir_path)

elif fs is None or any(os.path.exists(os.path.join(lib_dir_path, f)) for f in fs):
_log.debug("Retaining library subdir '%s' (found at %s)", lib_subdir, lib_dir_path)
found_subdirs.append(lib_subdir)
break

# if no library subdir was found, return None
if not found_subdirs:
return None
if full_path:
res = [os.path.join(root, subdir) for subdir in found_subdirs]
else:
res = found_subdirs
if only_one:
if len(res) == 1:
res = res[0]
else:
if fs is None and len(res) == 2:
# if both lib and lib64 were found, check if only one (exactly) has libraries;
# this is needed for software with library archives in lib64 but other files/directories in lib
lib_glob = ['*.%s' % ext for ext in ['a', get_shared_lib_ext()]]
has_libs = [any(glob.glob(os.path.join(root, subdir, f)) for f in lib_glob)
for subdir in found_subdirs]
if has_libs[0] and not has_libs[1]:
return res[0]
if has_libs[1] and not has_libs[0]:
return res[1]

raise EasyBuildError("Multiple library subdirectories found for %s in %s: %s",
name, root, ', '.join(found_subdirs))
return res
else:
# return None if software package root could not be determined
elif build_option('extended_dry_run'):
found_subdirs.append(lib_subdir)
break

# if no library subdir was found, return None
if not found_subdirs:
return None
if full_path:
res = [os.path.join(root, subdir) for subdir in found_subdirs]
else:
res = found_subdirs
if only_one:
if len(res) == 1:
res = res[0]
else:
if fs is None and len(res) == 2:
# if both lib and lib64 were found, check if only one (exactly) has libraries;
# this is needed for software with library archives in lib64 but other files/directories in lib
lib_glob = ['*.%s' % ext for ext in ['a', get_shared_lib_ext()]]
has_libs = [any(glob.glob(os.path.join(root, subdir, f)) for f in lib_glob)
for subdir in found_subdirs]
if has_libs[0] and not has_libs[1]:
return res[0]
if has_libs[1] and not has_libs[0]:
return res[1]

raise EasyBuildError("Multiple library subdirectories found for %s in %s: %s",
name, root, ', '.join(found_subdirs))
return res


def get_software_version_env_var_name(name):
Expand Down

0 comments on commit f35ae5e

Please sign in to comment.