From 510220edf0adc79682dd455d2d6df3741a680eea Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sun, 14 Dec 2025 22:12:38 +0100 Subject: [PATCH 1/2] fix logic in Cargo easyblock to determine value for 'finalpath' after extracting sources --- easybuild/easyblocks/generic/cargo.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/easybuild/easyblocks/generic/cargo.py b/easybuild/easyblocks/generic/cargo.py index 0d4c0eb4c48..05fcda5993b 100755 --- a/easybuild/easyblocks/generic/cargo.py +++ b/easybuild/easyblocks/generic/cargo.py @@ -319,21 +319,22 @@ def extract_step(self): extraction_dir = self.vendor_dir if is_vendor_crate else self.builddir self.log.info("Unpacking source of %s", src['name']) - existing_dirs = set(os.listdir(extraction_dir)) + existing_files = set(os.listdir(extraction_dir)) extract_file(src['path'], extraction_dir, cmd=src['cmd'], extra_options=self.cfg['unpack_options'], change_into_dir=False, trace=False) - new_extracted_dirs = set(os.listdir(extraction_dir)) - existing_dirs + new_extracted_files = set(os.listdir(extraction_dir)) - existing_files + new_extracted_dirs = sorted(x for x in new_extracted_files if os.path.isdir(os.path.join(extraction_dir, x))) + self.log.info(f"New directories found after extracting {src['name']}: {new_extracted_dirs}") if len(new_extracted_dirs) == 0: # Extraction went wrong raise EasyBuildError("Unpacking sources of '%s' failed", src['name']) - # There can be multiple folders but we just use the first new one as the finalpath - if len(new_extracted_dirs) > 1: - self.log.warning(f"Found multiple folders when extracting {src['name']}: " - f"{', '.join(new_extracted_dirs)}.") - src_dir = os.path.join(extraction_dir, new_extracted_dirs.pop()) + elif len(new_extracted_dirs) == 1: + src_dir = os.path.join(extraction_dir, new_extracted_dirs[0]) + else: + # if there are multiple subdirectories, we use parent directory as finalpath + src_dir = extraction_dir self.log.debug("Unpacked sources of %s into: %s", src['name'], src_dir) - src['finalpath'] = src_dir if self.cfg['offline']: From 707fddccdf440fd52845dbfea16a61dcad6b094a Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sun, 14 Dec 2025 22:14:57 +0100 Subject: [PATCH 2/2] fix long line in Cargo.extract_step --- easybuild/easyblocks/generic/cargo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/generic/cargo.py b/easybuild/easyblocks/generic/cargo.py index 05fcda5993b..2808408628a 100755 --- a/easybuild/easyblocks/generic/cargo.py +++ b/easybuild/easyblocks/generic/cargo.py @@ -323,7 +323,8 @@ def extract_step(self): extract_file(src['path'], extraction_dir, cmd=src['cmd'], extra_options=self.cfg['unpack_options'], change_into_dir=False, trace=False) new_extracted_files = set(os.listdir(extraction_dir)) - existing_files - new_extracted_dirs = sorted(x for x in new_extracted_files if os.path.isdir(os.path.join(extraction_dir, x))) + new_extracted_dirs = sorted(x for x in new_extracted_files + if os.path.isdir(os.path.join(extraction_dir, x))) self.log.info(f"New directories found after extracting {src['name']}: {new_extracted_dirs}") if len(new_extracted_dirs) == 0: