Skip to content

Commit

Permalink
Avoid recursion by always calling the original post_install_step()
Browse files Browse the repository at this point in the history
@boegel's method completely bypassed post_install_step() in easyblocks, so
I've added a simple check to see if it's used (a line printed to stdout).
  • Loading branch information
bartoldeman committed Dec 11, 2024
1 parent d86f53e commit 10b2a75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
32 changes: 19 additions & 13 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3110,22 +3110,13 @@ def print_post_install_messages(self):
print_msg(msg, log=self.log)

def post_install_step(self):
"""[DEPRECATED] Do some postprocessing."""
# this is for easyblocks calling super(EB_xxx, self).post_install_step()
# deprecation warning is below, in post_processing_step
return self.post_processing_step()

def post_processing_step(self):
"""
Do some postprocessing
[DEPRECATED] Do some postprocessing
- run post install commands if any were specified
"""

if self.post_install_step.__qualname__ != "EasyBlock.post_install_step":
self.log.deprecated(
"EasyBlock.post_install_step() is deprecated, use EasyBlock.post_processing_step() instead.",
'6.0',
)
# even though post_install_step is deprecated in easyblocks we need to keep this here until it is
# removed in 6.0 for easyblocks calling super(EB_xxx, self).post_install_step()
# The deprecation warning for those is below, in post_processing_step().

lib_dir = os.path.join(self.installdir, 'lib')
lib64_dir = os.path.join(self.installdir, 'lib64')
Expand Down Expand Up @@ -3153,6 +3144,21 @@ def post_processing_step(self):

self.fix_shebang()

def post_processing_step(self):
"""
Do some postprocessing
- run post install commands if any were specified
"""
# if post_install_step() is present in the easyblock print a deprecation warning
# with EB 6.0, post_install_step() can be renamed to post_processing_step, and this method deleted.

if self.post_install_step.__qualname__ != "EasyBlock.post_install_step":
self.log.deprecated(
"EasyBlock.post_install_step() is deprecated, use EasyBlock.post_processing_step() instead.",
'6.0',
)
return self.post_install_step()

def sanity_check_step(self, *args, **kwargs):
"""
Do a sanity check on the installation
Expand Down
4 changes: 3 additions & 1 deletion test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,12 @@ def test_post_processing_step(self):
toy_ec = EasyConfig(toy_ec_fn)
eb = EB_toy_deprecated(toy_ec)
eb.silent = True
with self.mocked_stdout_stderr() as (_, stderr):
with self.mocked_stdout_stderr() as (stdout, stderr):
eb.run_all_steps(True)

regex = re.compile(depr_msg, re.M)
stdout = stdout.getvalue()
self.assertTrue("This step is deprecated.\n" in stdout)
stderr = stderr.getvalue()
self.assertTrue(regex.search(stderr), f"Pattern {regex.pattern} found in: {stderr}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ class EB_toy_deprecated(EB_toy):

def post_install_step(self):
"""Any postprocessing for toy (deprecated)"""
print("This step is deprecated.")
super(EB_toy, self).post_install_step()

0 comments on commit 10b2a75

Please sign in to comment.