From 25ac1eeabe9a8e0ee41d138d1d1cc39448f4682b Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 28 Aug 2025 16:22:54 +0200 Subject: [PATCH] Improve error message when no files to copy where found in MakeCp easyblock --- easybuild/easyblocks/generic/makecp.py | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/easybuild/easyblocks/generic/makecp.py b/easybuild/easyblocks/generic/makecp.py index 561c0cd3b90..3405ef52f03 100644 --- a/easybuild/easyblocks/generic/makecp.py +++ b/easybuild/easyblocks/generic/makecp.py @@ -91,6 +91,14 @@ def install_step(self): mkdir(target, parents=True) + # first look for files in start dir + search_locations = [('start dir', self.start_dir)] + # use location of first unpacked source file as fallback location + try: + search_locations.append(('unpacked source dir', self.src[0]['finalpath'])) + except (IndexError, KeyError): + pass # Ignore if no source or source has not finalpath + for orig_files_spec in files_specs: if isinstance(orig_files_spec, tuple): files_spec = orig_files_spec[0] @@ -99,21 +107,16 @@ def install_step(self): files_spec = orig_files_spec dest = None - # first look for files in start dir - filepaths = glob.glob(os.path.join(self.cfg['start_dir'], files_spec)) - tup = (files_spec, self.cfg['start_dir'], filepaths) - self.log.debug("List of files matching '%s' in start dir %s: %s" % tup) - - if not filepaths and len(self.src) > 0 and 'finalpath' in self.src[0]: - # use location of first unpacked source file as fallback location - tup = (files_spec, self.cfg['start_dir']) - self.log.warning("No files matching '%s' found in start dir %s" % tup) - filepaths = glob.glob(os.path.join(self.src[0]['finalpath'], files_spec)) - self.log.debug("List of files matching '%s' in %s: %s" % (tup + (filepaths,))) + for desc, loc in search_locations: + filepaths = glob.glob(os.path.join(loc, files_spec)) + if filepaths: + break + self.log.warning("No files matching '%s' found in %s %s", files_spec, desc, loc) # there should be at least one match per file spec if not filepaths: - raise EasyBuildError("No files matching '%s' found anywhere.", files_spec) + raise EasyBuildError("No files matching '%s' found in %s.", + files_spec, ' or '.join(loc[1] for loc in search_locations)) if dest and len(filepaths) != 1: raise EasyBuildError("When a list with new names has been specified, the original file spec can "