Skip to content

Commit 10b2a75

Browse files
committed
Avoid recursion by always calling the original post_install_step()
@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).
1 parent d86f53e commit 10b2a75

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

easybuild/framework/easyblock.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,22 +3110,13 @@ def print_post_install_messages(self):
31103110
print_msg(msg, log=self.log)
31113111

31123112
def post_install_step(self):
3113-
"""[DEPRECATED] Do some postprocessing."""
3114-
# this is for easyblocks calling super(EB_xxx, self).post_install_step()
3115-
# deprecation warning is below, in post_processing_step
3116-
return self.post_processing_step()
3117-
3118-
def post_processing_step(self):
31193113
"""
3120-
Do some postprocessing
3114+
[DEPRECATED] Do some postprocessing
31213115
- run post install commands if any were specified
31223116
"""
3123-
3124-
if self.post_install_step.__qualname__ != "EasyBlock.post_install_step":
3125-
self.log.deprecated(
3126-
"EasyBlock.post_install_step() is deprecated, use EasyBlock.post_processing_step() instead.",
3127-
'6.0',
3128-
)
3117+
# even though post_install_step is deprecated in easyblocks we need to keep this here until it is
3118+
# removed in 6.0 for easyblocks calling super(EB_xxx, self).post_install_step()
3119+
# The deprecation warning for those is below, in post_processing_step().
31293120

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

31543145
self.fix_shebang()
31553146

3147+
def post_processing_step(self):
3148+
"""
3149+
Do some postprocessing
3150+
- run post install commands if any were specified
3151+
"""
3152+
# if post_install_step() is present in the easyblock print a deprecation warning
3153+
# with EB 6.0, post_install_step() can be renamed to post_processing_step, and this method deleted.
3154+
3155+
if self.post_install_step.__qualname__ != "EasyBlock.post_install_step":
3156+
self.log.deprecated(
3157+
"EasyBlock.post_install_step() is deprecated, use EasyBlock.post_processing_step() instead.",
3158+
'6.0',
3159+
)
3160+
return self.post_install_step()
3161+
31563162
def sanity_check_step(self, *args, **kwargs):
31573163
"""
31583164
Do a sanity check on the installation

test/framework/easyblock.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,12 @@ def test_post_processing_step(self):
10621062
toy_ec = EasyConfig(toy_ec_fn)
10631063
eb = EB_toy_deprecated(toy_ec)
10641064
eb.silent = True
1065-
with self.mocked_stdout_stderr() as (_, stderr):
1065+
with self.mocked_stdout_stderr() as (stdout, stderr):
10661066
eb.run_all_steps(True)
10671067

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

test/framework/sandbox/easybuild/easyblocks/t/toy_deprecated.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ class EB_toy_deprecated(EB_toy):
3636

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

0 commit comments

Comments
 (0)