Skip to content

Commit

Permalink
disable non-empty check on search path drectories for fake module files
Browse files Browse the repository at this point in the history
  • Loading branch information
lexming committed Sep 23, 2024
1 parent df505cf commit 5680038
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,9 +1559,10 @@ def make_module_group_check(self):

return txt

def make_module_req(self):
def make_module_req(self, fake=False):
"""
Generate the environment-variables required to run the module.
Fake modules can set search paths to empty directories.
"""
mod_lines = ['\n']

Expand All @@ -1585,7 +1586,7 @@ def make_module_req(self):
mod_env_paths = search_paths
else:
for sp in search_paths:
mod_env_paths.extend(self._expand_module_search_path(sp, recursive))
mod_env_paths.extend(self._expand_module_search_path(sp, recursive, fake=fake))

if mod_env_paths:
mod_env_paths = nub(mod_env_paths) # remove duplicates
Expand Down Expand Up @@ -1616,10 +1617,12 @@ def make_module_req_guess(self):
'CMAKE_LIBRARY_PATH': ['lib64'], # only needed for installations whith standalone lib64
}

def _expand_module_search_path(self, search_path, recursive):
def _expand_module_search_path(self, search_path, recursive, fake=False):
"""
Expand given path glob and return list of paths that are suitable to be
used as search paths in environment module
Expand given path glob and return list of suitable paths to be used as search paths:
- Files must exist and directories be non-empty
- Fake modules can set search paths to empty directories
- Search paths to 'lib64' symlinked to 'lib' are discarded
"""
# Expand globs but only if the string is non-empty
# empty string is a valid value here (i.e. to prepend the installation prefix root directory)
Expand All @@ -1628,6 +1631,7 @@ def _expand_module_search_path(self, search_path, recursive):

retained_search_paths = []
for abs_path in exp_search_paths:
# return relative paths
tentative_path = os.path.relpath(abs_path, start=self.installdir)
tentative_path = "" if tentative_path == "." else tentative_path # use empty string instead of dot

Expand All @@ -1640,7 +1644,7 @@ def _expand_module_search_path(self, search_path, recursive):
break

# only retain paths to directories that contain at least one file
if os.path.isdir(abs_path) and not dir_contains_files(abs_path, recursive=recursive):
if os.path.isdir(abs_path) and not dir_contains_files(abs_path, recursive=recursive) and not fake:
self.log.debug("Discarded search path to empty directory: %s", tentative_path)
break

Expand Down Expand Up @@ -3785,7 +3789,7 @@ def make_module_step(self, fake=False):
txt += self.make_module_deppaths()
txt += self.make_module_dep()
txt += self.make_module_extend_modpath()
txt += self.make_module_req()
txt += self.make_module_req(fake=fake)
txt += self.make_module_extra()
txt += self.make_module_footer()

Expand Down

0 comments on commit 5680038

Please sign in to comment.