Skip to content

Commit abf8fbe

Browse files
authored
Merge pull request #4715 from bartoldeman/post-install-step-rename
Rename `post_install_step` to `post_processing_step` + deprecate use of `post_install_step`
2 parents 9fcee6b + 10b2a75 commit abf8fbe

File tree

6 files changed

+135
-4
lines changed

6 files changed

+135
-4
lines changed

easybuild/framework/easyblock.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,9 +3141,12 @@ def print_post_install_messages(self):
31413141

31423142
def post_install_step(self):
31433143
"""
3144-
Do some postprocessing
3144+
[DEPRECATED] Do some postprocessing
31453145
- run post install commands if any were specified
31463146
"""
3147+
# even though post_install_step is deprecated in easyblocks we need to keep this here until it is
3148+
# removed in 6.0 for easyblocks calling super(EB_xxx, self).post_install_step()
3149+
# The deprecation warning for those is below, in post_processing_step().
31473150

31483151
lib_dir = os.path.join(self.installdir, 'lib')
31493152
lib64_dir = os.path.join(self.installdir, 'lib64')
@@ -3171,6 +3174,21 @@ def post_install_step(self):
31713174

31723175
self.fix_shebang()
31733176

3177+
def post_processing_step(self):
3178+
"""
3179+
Do some postprocessing
3180+
- run post install commands if any were specified
3181+
"""
3182+
# if post_install_step() is present in the easyblock print a deprecation warning
3183+
# with EB 6.0, post_install_step() can be renamed to post_processing_step, and this method deleted.
3184+
3185+
if self.post_install_step.__qualname__ != "EasyBlock.post_install_step":
3186+
self.log.deprecated(
3187+
"EasyBlock.post_install_step() is deprecated, use EasyBlock.post_processing_step() instead.",
3188+
'6.0',
3189+
)
3190+
return self.post_install_step()
3191+
31743192
def sanity_check_step(self, *args, **kwargs):
31753193
"""
31763194
Do a sanity check on the installation
@@ -4224,7 +4242,7 @@ def install_step_spec(initial):
42244242
# part 3: post-iteration part
42254243
steps_part3 = [
42264244
(POSTITER_STEP, 'restore after iterating', [lambda x: x.post_iter_step], False),
4227-
(POSTPROC_STEP, 'postprocessing', [lambda x: x.post_install_step], True),
4245+
(POSTPROC_STEP, 'postprocessing', [lambda x: x.post_processing_step], True),
42284246
(SANITYCHECK_STEP, 'sanity checking', [lambda x: x.sanity_check_step], True),
42294247
(CLEANUP_STEP, 'cleaning up', [lambda x: x.cleanup_step], False),
42304248
(MODULE_STEP, 'creating module', [lambda x: x.make_module_step], False),

test/framework/docs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
| | |-- DeprecatedDummyExtension
6565
| | | |-- ChildDeprecatedDummyExtension
6666
| |-- EB_toy
67+
| | |-- EB_toy_deprecated
6768
| | |-- EB_toy_eula
6869
| | |-- EB_toytoy
6970
| |-- Toy_Extension
@@ -78,6 +79,7 @@
7879
| | |-- DeprecatedDummyExtension
7980
| | | |-- ChildDeprecatedDummyExtension
8081
| |-- EB_toy
82+
| | |-- EB_toy_deprecated
8183
| | |-- EB_toy_eula
8284
| | |-- EB_toytoy
8385
| |-- Toy_Extension""" # noqa
@@ -104,6 +106,7 @@
104106
| | |-- DeprecatedDummyExtension (easybuild.easyblocks.generic.deprecateddummyextension @ %(topdir)s/generic/deprecateddummyextension.py)
105107
| | | |-- ChildDeprecatedDummyExtension (easybuild.easyblocks.generic.childdeprecateddummyextension @ %(topdir)s/generic/childdeprecateddummyextension.py)
106108
| |-- EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
109+
| | |-- EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
107110
| | |-- EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
108111
| | |-- EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
109112
| |-- Toy_Extension (easybuild.easyblocks.generic.toy_extension @ %(topdir)s/generic/toy_extension.py)
@@ -118,6 +121,7 @@
118121
| | |-- DeprecatedDummyExtension (easybuild.easyblocks.generic.deprecateddummyextension @ %(topdir)s/generic/deprecateddummyextension.py)
119122
| | | |-- ChildDeprecatedDummyExtension (easybuild.easyblocks.generic.childdeprecateddummyextension @ %(topdir)s/generic/childdeprecateddummyextension.py)
120123
| |-- EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
124+
| | |-- EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
121125
| | |-- EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
122126
| | |-- EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
123127
| |-- Toy_Extension (easybuild.easyblocks.generic.toy_extension @ %(topdir)s/generic/toy_extension.py)""" # noqa
@@ -157,6 +161,7 @@
157161
158162
* EB_toy
159163
164+
* EB_toy_deprecated
160165
* EB_toy_eula
161166
* EB_toytoy
162167
@@ -183,6 +188,7 @@
183188
184189
* EB_toy
185190
191+
* EB_toy_deprecated
186192
* EB_toy_eula
187193
* EB_toytoy
188194
@@ -225,6 +231,7 @@
225231
226232
* EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
227233
234+
* EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
228235
* EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
229236
* EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
230237
@@ -251,6 +258,7 @@
251258
252259
* EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
253260
261+
* EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
254262
* EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
255263
* EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
256264
@@ -280,6 +288,7 @@
280288
- DeprecatedDummyExtension
281289
- ChildDeprecatedDummyExtension
282290
- EB_toy
291+
- EB_toy_deprecated
283292
- EB_toy_eula
284293
- EB_toytoy
285294
- Toy_Extension
@@ -294,6 +303,7 @@
294303
- DeprecatedDummyExtension
295304
- ChildDeprecatedDummyExtension
296305
- EB_toy
306+
- EB_toy_deprecated
297307
- EB_toy_eula
298308
- EB_toytoy
299309
- Toy_Extension""" # noqa
@@ -320,6 +330,7 @@
320330
- DeprecatedDummyExtension (easybuild.easyblocks.generic.deprecateddummyextension @ %(topdir)s/generic/deprecateddummyextension.py)
321331
- ChildDeprecatedDummyExtension (easybuild.easyblocks.generic.childdeprecateddummyextension @ %(topdir)s/generic/childdeprecateddummyextension.py)
322332
- EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
333+
- EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
323334
- EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
324335
- EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
325336
- Toy_Extension (easybuild.easyblocks.generic.toy_extension @ %(topdir)s/generic/toy_extension.py)
@@ -334,6 +345,7 @@
334345
- DeprecatedDummyExtension (easybuild.easyblocks.generic.deprecateddummyextension @ %(topdir)s/generic/deprecateddummyextension.py)
335346
- ChildDeprecatedDummyExtension (easybuild.easyblocks.generic.childdeprecateddummyextension @ %(topdir)s/generic/childdeprecateddummyextension.py)
336347
- EB_toy (easybuild.easyblocks.toy @ %(topdir)s/t/toy.py)
348+
- EB_toy_deprecated (easybuild.easyblocks.toy_deprecated @ %(topdir)s/t/toy_deprecated.py)
337349
- EB_toy_eula (easybuild.easyblocks.toy_eula @ %(topdir)s/t/toy_eula.py)
338350
- EB_toytoy (easybuild.easyblocks.toytoy @ %(topdir)s/t/toytoy.py)
339351
- Toy_Extension (easybuild.easyblocks.generic.toy_extension @ %(topdir)s/generic/toy_extension.py)""" # noqa

test/framework/easyblock.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from easybuild.tools import LooseVersion, config
5151
from easybuild.tools.build_log import EasyBuildError
5252
from easybuild.tools.config import get_module_syntax, update_build_option
53+
from easybuild.tools.environment import modify_env
5354
from easybuild.tools.filetools import change_dir, copy_dir, copy_file, mkdir, read_file, remove_dir, remove_file
5455
from easybuild.tools.filetools import verify_checksum, write_file
5556
from easybuild.tools.module_generator import module_generator
@@ -1020,6 +1021,60 @@ def test_handle_iterate_opts(self):
10201021
self.assertEqual(eb.cfg.iterating, False)
10211022
self.assertEqual(eb.cfg['configopts'], ["--opt1 --anotheropt", "--opt2", "--opt3 --optbis"])
10221023

1024+
def test_post_processing_step(self):
1025+
"""Test post_processing_step and deprecated post_install_step."""
1026+
init_config(build_options={'silent': True})
1027+
1028+
test_ecs_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
1029+
toy_ec_fn = os.path.join(test_ecs_dir, 't', 'toy', 'toy-0.0.eb')
1030+
1031+
# these imports only work here, since EB_toy is a test easyblock
1032+
from easybuild.easyblocks.toy import EB_toy
1033+
from easybuild.easyblocks.toy_deprecated import EB_toy_deprecated
1034+
1035+
cwd = os.getcwd()
1036+
toy_ec = EasyConfig(toy_ec_fn)
1037+
eb = EB_toy_deprecated(toy_ec)
1038+
eb.silent = True
1039+
depr_msg = r"EasyBlock.post_install_step\(\) is deprecated, use EasyBlock.post_processing_step\(\) instead"
1040+
expected_error = r"DEPRECATED \(since v6.0\).*" + depr_msg
1041+
with self.mocked_stdout_stderr():
1042+
self.assertErrorRegex(EasyBuildError, expected_error, eb.run_all_steps, True)
1043+
1044+
change_dir(cwd)
1045+
toy_ec = EasyConfig(toy_ec_fn)
1046+
eb = EB_toy(toy_ec)
1047+
eb.silent = True
1048+
with self.mocked_stdout_stderr() as (_, stderr):
1049+
eb.run_all_steps(True)
1050+
# no deprecation warning
1051+
stderr = stderr.getvalue()
1052+
self.assertFalse(stderr)
1053+
1054+
libtoy_post_a = os.path.join(eb.installdir, 'lib', 'libtoy_post.a')
1055+
self.assertExists(libtoy_post_a)
1056+
1057+
# check again with toy easyblock that still uses post_install_step,
1058+
# to verify that the expected file is being created when deprecated functionality is allow
1059+
remove_file(libtoy_post_a)
1060+
modify_env(os.environ, self.orig_environ, verbose=False)
1061+
change_dir(cwd)
1062+
1063+
self.allow_deprecated_behaviour()
1064+
toy_ec = EasyConfig(toy_ec_fn)
1065+
eb = EB_toy_deprecated(toy_ec)
1066+
eb.silent = True
1067+
with self.mocked_stdout_stderr() as (stdout, stderr):
1068+
eb.run_all_steps(True)
1069+
1070+
regex = re.compile(depr_msg, re.M)
1071+
stdout = stdout.getvalue()
1072+
self.assertTrue("This step is deprecated.\n" in stdout)
1073+
stderr = stderr.getvalue()
1074+
self.assertTrue(regex.search(stderr), f"Pattern {regex.pattern} found in: {stderr}")
1075+
1076+
self.assertExists(libtoy_post_a)
1077+
10231078
def test_extensions_step(self):
10241079
"""Test the extensions_step"""
10251080
init_config(build_options={'silent': True})

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def install_step(self, name=None):
142142
mkdir(libdir, parents=True)
143143
write_file(os.path.join(libdir, 'lib%s.a' % name), name.upper())
144144

145+
def post_processing_step(self):
146+
"""Any postprocessing for toy"""
147+
libdir = os.path.join(self.installdir, 'lib')
148+
write_file(os.path.join(libdir, 'lib%s_post.a' % self.name), self.name.upper())
149+
super(EB_toy, self).post_processing_step()
150+
145151
@property
146152
def required_deps(self):
147153
"""Return list of required dependencies for this extension."""
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
##
2+
# Copyright 2009-2024 Ghent University
3+
#
4+
# This file is part of EasyBuild,
5+
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
6+
# with support of Ghent University (http://ugent.be/hpc),
7+
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
8+
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
9+
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
10+
#
11+
# https://github.com/easybuilders/easybuild
12+
#
13+
# EasyBuild is free software: you can redistribute it and/or modify
14+
# it under the terms of the GNU General Public License as published by
15+
# the Free Software Foundation v2.
16+
#
17+
# EasyBuild is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
24+
##
25+
"""
26+
(deprecated) EasyBuild support for building and installing toy, implemented as an easyblock
27+
28+
@author: Bart Oldeman (McGill University, Calcul Quebec, Digital Research Alliance of Canada)
29+
"""
30+
31+
from easybuild.easyblocks.toy import EB_toy
32+
33+
34+
class EB_toy_deprecated(EB_toy):
35+
"""Support for building/installing toy with deprecated post_install step."""
36+
37+
def post_install_step(self):
38+
"""Any postprocessing for toy (deprecated)"""
39+
print("This step is deprecated.")
40+
super(EB_toy, self).post_install_step()

test/framework/toy_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,8 +2436,8 @@ def test_sanity_check_paths_lib64(self):
24362436
"rm -f %(installdir)s/lib64",
24372437
# create empty lib64 dir
24382438
"mkdir %(installdir)s/lib64",
2439-
# move libtoy.a
2440-
"mv %(installdir)s/lib/libtoy.a %(installdir)s/lib64/libtoy.a",
2439+
# move libtoy*.a
2440+
"mv %(installdir)s/lib/libtoy*.a %(installdir)s/lib64/",
24412441
])
24422442
ectxt = re.sub("postinstallcmds.*", "postinstallcmds = ['%s']" % postinstallcmd, ectxt)
24432443

0 commit comments

Comments
 (0)