-
Notifications
You must be signed in to change notification settings - Fork 311
fix logic in Cargo easyblock to determine value for 'finalpath' after extracting sources #4022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,21 +319,23 @@ 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This introduces a change to previous behavior which used the result of This is also problematic, see easybuilders/easybuild-framework#4922 My tests included that PR so I added the change to #3665 to not rely on the (changed by 4922) result but misunderstood the (questionable) logic.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is essentially fixing a regression that was introduced in #3665, so it should be merged. The installation of I'm testing this very broadly (see list of easyconfig files passed to the bot) deliberately to make sure this doesn't break any other easyconfigs we have currently. I consider this a (small) blocker for the release of EasyBuild v5.2.0. If more steps are needed afterwards to make things more sensible, that's OK, but without this fix the logic used to determine path to set in So, this is a step forward, but probably not the end of the ride.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but it does not restore the behavior prior to #3665 if this is what the intention was. The prior behavior included files when checking which folder to use, see The fix here only happens to work because there are multiple folders. But it would still trigger the regression if The previous logic was:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it won't work in a theoretical case, but if it works in practice for all easyconfigs we have, it should still go in. We can follow up in a subsequent PR with more fixes if needed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just wanted to make sure you are aware that the added line, filtering for directories, is a breaking change, similar to what happened in #3665 and introduces a difference in folder-detection to a) Although it is at least (more) deterministic than after #3665 so I'm fine with that if it works for the tested ECs |
||
| 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']: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not name this "files"? That would be as wrong as "dirs", so maybe "paths"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, but not going to change this now, since it's a local variable, and if we're strict that would require another round of testing...
Please open a follow-up PR (or squeeze the renaming of the local variable in another PR for
Cargoeasyblock)