Skip to content

Commit 5a2f3e8

Browse files
authored
Merge pull request #4629 from Flamefire/source-step
Rename '`source`' step to '`extract`' (affects `skipsteps` easyconfig parameter + `--stop` option)
2 parents cad3801 + a41de82 commit 5a2f3e8

File tree

8 files changed

+127
-147
lines changed

8 files changed

+127
-147
lines changed

easybuild/framework/easyblock.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@
8686
from easybuild.tools.filetools import get_cwd, get_source_tarball_from_git, is_alt_pypi_url
8787
from easybuild.tools.filetools import is_binary, is_sha256_checksum, mkdir, move_file, move_logs, read_file, remove_dir
8888
from easybuild.tools.filetools import remove_file, remove_lock, verify_checksum, weld_paths, write_file, symlink
89-
from easybuild.tools.hooks import BUILD_STEP, CLEANUP_STEP, CONFIGURE_STEP, EXTENSIONS_STEP, FETCH_STEP, INSTALL_STEP
90-
from easybuild.tools.hooks import MODULE_STEP, MODULE_WRITE, PACKAGE_STEP, PATCH_STEP, PERMISSIONS_STEP, POSTITER_STEP
91-
from easybuild.tools.hooks import POSTPROC_STEP, PREPARE_STEP, READY_STEP, SANITYCHECK_STEP, SOURCE_STEP
92-
from easybuild.tools.hooks import SINGLE_EXTENSION, TEST_STEP, TESTCASES_STEP, load_hooks, run_hook
89+
from easybuild.tools.hooks import (
90+
BUILD_STEP, CLEANUP_STEP, CONFIGURE_STEP, EXTENSIONS_STEP, EXTRACT_STEP, FETCH_STEP, INSTALL_STEP, MODULE_STEP,
91+
MODULE_WRITE, PACKAGE_STEP, PATCH_STEP, PERMISSIONS_STEP, POSTITER_STEP, POSTPROC_STEP, PREPARE_STEP, READY_STEP,
92+
SANITYCHECK_STEP, SINGLE_EXTENSION, TEST_STEP, TESTCASES_STEP, load_hooks, run_hook,
93+
)
9394
from easybuild.tools.run import RunShellCmdError, raise_run_shell_cmd_error, run_shell_cmd
9495
from easybuild.tools.jenkins import write_to_xml
9596
from easybuild.tools.module_generator import ModuleGeneratorLua, ModuleGeneratorTcl, module_generator, dependencies_for
@@ -4156,7 +4157,7 @@ def install_step_spec(initial):
41564157
# format for step specifications: (step_name, description, list of functions, skippable)
41574158

41584159
# core steps that are part of the iterated loop
4159-
extract_step_spec = (SOURCE_STEP, "unpacking", [lambda x: x.extract_step], True)
4160+
extract_step_spec = (EXTRACT_STEP, "unpacking", [lambda x: x.extract_step], True)
41604161
patch_step_spec = (PATCH_STEP, 'patching', [lambda x: x.patch_step], True)
41614162
prepare_step_spec = (PREPARE_STEP, 'preparing', [lambda x: x.prepare_step], False)
41624163
configure_step_spec = (CONFIGURE_STEP, 'configuring', [lambda x: x.configure_step], True)

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
from easybuild.tools.filetools import convert_name, copy_file, create_index, decode_class_name, encode_class_name
7373
from easybuild.tools.filetools import find_backup_name_candidate, find_easyconfigs, load_index
7474
from easybuild.tools.filetools import read_file, write_file
75-
from easybuild.tools.hooks import PARSE, load_hooks, run_hook
75+
from easybuild.tools.hooks import PARSE, EXTRACT_STEP, STEP_NAMES, load_hooks, run_hook
7676
from easybuild.tools.module_naming_scheme.mns import DEVEL_MODULE_SUFFIX
7777
from easybuild.tools.module_naming_scheme.utilities import avail_module_naming_schemes, det_full_ec_version
7878
from easybuild.tools.module_naming_scheme.utilities import det_hidden_modname, is_valid_module_name
@@ -860,9 +860,25 @@ def validate(self, check_osdeps=True):
860860
self.log.info("Not checking OS dependencies")
861861

862862
self.log.info("Checking skipsteps")
863-
if not isinstance(self._config['skipsteps'][0], (list, tuple,)):
863+
skipsteps = self._config['skipsteps'][0]
864+
if not isinstance(skipsteps, (list, tuple,)):
864865
raise EasyBuildError('Invalid type for skipsteps. Allowed are list or tuple, got %s (%s)',
865-
type(self._config['skipsteps'][0]), self._config['skipsteps'][0])
866+
type(skipsteps), skipsteps)
867+
unknown_step_names = [step for step in skipsteps if step not in STEP_NAMES]
868+
if unknown_step_names:
869+
error_lines = ["Found one or more unknown step names in 'skipsteps' easyconfig parameter:"]
870+
for step in unknown_step_names:
871+
error_line = "* %s" % step
872+
# try to find close match, may be just a typo in the step name
873+
close_matches = difflib.get_close_matches(step, STEP_NAMES, 2, 0.8)
874+
# 'source' step was renamed to 'extract' in EasyBuild 5.0, see provide a useful suggestion in that case;
875+
# see https://github.com/easybuilders/easybuild-framework/pull/4629
876+
if not close_matches and step == 'source':
877+
close_matches.append(EXTRACT_STEP)
878+
if close_matches:
879+
error_line += " (did you mean %s?)" % ', or '.join("'%s'" % s for s in close_matches)
880+
error_lines.append(error_line)
881+
raise EasyBuildError('\n'.join(error_lines))
866882

867883
self.log.info("Checking build option lists")
868884
self.validate_iterate_opts_lists()

easybuild/tools/hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
CLEANUP_STEP = 'cleanup'
4545
CONFIGURE_STEP = 'configure'
4646
EXTENSIONS_STEP = 'extensions'
47+
EXTRACT_STEP = 'extract'
4748
FETCH_STEP = 'fetch'
4849
INSTALL_STEP = 'install'
4950
MODULE_STEP = 'module'
@@ -55,7 +56,6 @@
5556
PREPARE_STEP = 'prepare'
5657
READY_STEP = 'ready'
5758
SANITYCHECK_STEP = 'sanitycheck'
58-
SOURCE_STEP = 'source'
5959
TEST_STEP = 'test'
6060
TESTCASES_STEP = 'testcases'
6161

@@ -77,7 +77,7 @@
7777
HOOK_SUFF = '_hook'
7878

7979
# list of names for steps in installation procedure (in order of execution)
80-
STEP_NAMES = [FETCH_STEP, READY_STEP, SOURCE_STEP, PATCH_STEP, PREPARE_STEP, CONFIGURE_STEP, BUILD_STEP, TEST_STEP,
80+
STEP_NAMES = [FETCH_STEP, READY_STEP, EXTRACT_STEP, PATCH_STEP, PREPARE_STEP, CONFIGURE_STEP, BUILD_STEP, TEST_STEP,
8181
INSTALL_STEP, EXTENSIONS_STEP, POSTITER_STEP, POSTPROC_STEP, SANITYCHECK_STEP, CLEANUP_STEP, MODULE_STEP,
8282
PERMISSIONS_STEP, PACKAGE_STEP, TESTCASES_STEP]
8383

easybuild/tools/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from easybuild.base import fancylogger # build_log should always stay there, to ensure EasyBuildLog
5252
from easybuild.base.fancylogger import setLogLevel
5353
from easybuild.base.generaloption import GeneralOption
54-
from easybuild.framework.easyblock import MODULE_ONLY_STEPS, SOURCE_STEP, FETCH_STEP, EasyBlock
54+
from easybuild.framework.easyblock import MODULE_ONLY_STEPS, EXTRACT_STEP, FETCH_STEP, EasyBlock
5555
from easybuild.framework.easyconfig import EASYCONFIGS_PKG_SUBDIR
5656
from easybuild.framework.easyconfig.easyconfig import HAVE_AUTOPEP8
5757
from easybuild.framework.easyconfig.format.one import EB_FORMAT_EXTENSION
@@ -299,7 +299,7 @@ def basic_options(self):
299299
'skip': ("Skip existing software (useful for installing additional packages)",
300300
None, 'store_true', False, 'k'),
301301
'stop': ("Stop the installation after certain step",
302-
'choice', 'store_or_None', SOURCE_STEP, 's', all_stops),
302+
'choice', 'store_or_None', EXTRACT_STEP, 's', all_stops),
303303
'strict': ("Set strictness level", 'choice', 'store', WARN, strictness_options),
304304
})
305305

test/framework/hooks.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"""
3030
import os
3131
import sys
32+
import textwrap
3233
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
3334
from unittest import TextTestRunner
3435

@@ -280,22 +281,24 @@ def test_verify_hooks(self):
280281
self.assertEqual(verify_hooks(hooks), None)
281282

282283
test_broken_hooks_pymod = os.path.join(self.test_prefix, 'test_broken_hooks.py')
283-
test_hooks_txt = '\n'.join([
284-
'',
285-
'def there_is_no_such_hook():',
286-
' pass',
287-
'def stat_hook(self):',
288-
' pass',
289-
'def post_source_hook(self):',
290-
' pass',
291-
'def install_hook(self):',
292-
' pass',
293-
])
284+
test_hooks_txt = textwrap.dedent("""
285+
def there_is_no_such_hook():
286+
pass
287+
def stat_hook(self):
288+
pass
289+
def post_source_hook(self):
290+
pass
291+
def post_extract_hook(self):
292+
pass
293+
def install_hook(self):
294+
pass
295+
""")
294296

295297
write_file(test_broken_hooks_pymod, test_hooks_txt)
296298

297299
error_msg_pattern = r"Found one or more unknown hooks:\n"
298300
error_msg_pattern += r"\* install_hook \(did you mean 'pre_install_hook', or 'post_install_hook'\?\)\n"
301+
error_msg_pattern += r"\* post_source_hook \(did you mean .*'\?\)\n"
299302
error_msg_pattern += r"\* stat_hook \(did you mean 'start_hook'\?\)\n"
300303
error_msg_pattern += r"\* there_is_no_such_hook\n\n"
301304
error_msg_pattern += r"Run 'eb --avail-hooks' to get an overview of known hooks"

0 commit comments

Comments
 (0)