Skip to content

Commit

Permalink
fix use of alternate/alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
jfgrimm committed Jun 10, 2024
1 parent 4223ede commit 8d73499
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,10 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
if PYPI_PKG_URL_PATTERN in fullurl and not is_alt_pypi_url(fullurl):
alt_url = derive_alt_pypi_url(fullurl)
if alt_url:
_log.debug("Using alternate PyPI URL for %s: %s", fullurl, alt_url)
_log.debug("Using alternative PyPI URL for %s: %s", fullurl, alt_url)
fullurl = alt_url
else:
_log.debug("Failed to derive alternate PyPI URL for %s, so retaining the original", fullurl)
_log.debug("Failed to derive alternative PyPI URL for %s, so retaining the original", fullurl)

if self.dry_run:
self.dry_run_msg(" * %s will be downloaded to %s", filename, targetpath)
Expand Down
34 changes: 17 additions & 17 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
from easybuild.framework.easyconfig.format.format import DEPENDENCY_PARAMETERS
from easybuild.framework.easyconfig.format.one import EB_FORMAT_EXTENSION, retrieve_blocks_in_spec
from easybuild.framework.easyconfig.licenses import EASYCONFIG_LICENSES_DICT
from easybuild.framework.easyconfig.parser import ALTERNATE_PARAMETERS, DEPRECATED_PARAMETERS, REPLACED_PARAMETERS
from easybuild.framework.easyconfig.parser import ALTERNATIVE_EASYCONFIG_PARAMETERS, DEPRECATED_EASYCONFIG_PARAMETERS, REPLACED_PARAMETERS
from easybuild.framework.easyconfig.parser import EasyConfigParser, fetch_parameters_from_easyconfig
from easybuild.framework.easyconfig.templates import ALTERNATE_TEMPLATES, DEPRECATED_TEMPLATES, TEMPLATE_CONSTANTS
from easybuild.framework.easyconfig.templates import ALTERNATIVE_EASYCONFIG_TEMPLATES, DEPRECATED_EASYCONFIG_TEMPLATES, TEMPLATE_CONSTANTS
from easybuild.framework.easyconfig.templates import TEMPLATE_NAMES_DYNAMIC, template_constant_dict
from easybuild.tools import LooseVersion
from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg
Expand Down Expand Up @@ -119,11 +119,11 @@ def handle_deprecated_or_replaced_easyconfig_parameters(ec_method):
def new_ec_method(self, key, *args, **kwargs):
"""Check whether any replace easyconfig parameters are still used"""
# map deprecated parameters to their replacements, issue deprecation warning(/error)
if key in ALTERNATE_PARAMETERS:
key = ALTERNATE_PARAMETERS[key]
elif key in DEPRECATED_PARAMETERS:
if key in ALTERNATIVE_EASYCONFIG_PARAMETERS:
key = ALTERNATIVE_EASYCONFIG_PARAMETERS[key]
elif key in DEPRECATED_EASYCONFIG_PARAMETERS:
depr_key = key
key, ver = DEPRECATED_PARAMETERS[depr_key]
key, ver = DEPRECATED_EASYCONFIG_PARAMETERS[depr_key]
_log.deprecated("Easyconfig parameter '%s' is deprecated, use '%s' instead" % (depr_key, key), ver)
elif key in REPLACED_PARAMETERS:
_log.nosupport("Easyconfig parameter '%s' is replaced by '%s'" % (key, REPLACED_PARAMETERS[key]), '2.0')
Expand Down Expand Up @@ -182,7 +182,7 @@ def triage_easyconfig_params(variables, ec):

for key in variables:
# validations are skipped, just set in the config
if any(key in d for d in (ec, DEPRECATED_PARAMETERS.keys(), ALTERNATE_PARAMETERS.keys())):
if any(key in d for d in (ec, DEPRECATED_EASYCONFIG_PARAMETERS.keys(), ALTERNATIVE_EASYCONFIG_PARAMETERS.keys())):
ec_params[key] = variables[key]
_log.debug("setting config option %s: value %s (type: %s)", key, ec_params[key], type(ec_params[key]))
elif key in REPLACED_PARAMETERS:
Expand Down Expand Up @@ -661,7 +661,7 @@ def set_keys(self, params):
with self.disable_templating():
for key in sorted(params.keys()):
# validations are skipped, just set in the config
if any(key in x.keys() for x in (self._config, ALTERNATE_PARAMETERS, DEPRECATED_PARAMETERS)):
if any(key in x.keys() for x in (self._config, ALTERNATIVE_EASYCONFIG_PARAMETERS, DEPRECATED_EASYCONFIG_PARAMETERS)):
self[key] = params[key]
self.log.info("setting easyconfig parameter %s: value %s (type: %s)",
key, self[key], type(self[key]))
Expand Down Expand Up @@ -1998,33 +1998,33 @@ def resolve_template(value, tmpl_dict):
try:
value = value % tmpl_dict
except KeyError:
# check if any alternate and/or deprecated templates resolve
# check if any alternative and/or deprecated templates resolve
try:
orig_value = value
# map old templates to new values for alternate and deprecated templates
# map old templates to new values for alternative and deprecated templates
alt_map = {old_tmpl: tmpl_dict[new_tmpl] for (old_tmpl, new_tmpl) in
ALTERNATE_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}
alt_map2 = {new_tmpl: tmpl_dict[old_tmpl] for (old_tmpl, new_tmpl) in
ALTERNATE_TEMPLATES.items() if old_tmpl in tmpl_dict.keys()}
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if old_tmpl in tmpl_dict.keys()}
depr_map = {old_tmpl: tmpl_dict[new_tmpl] for (old_tmpl, (new_tmpl, ver)) in
DEPRECATED_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}
DEPRECATED_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}

# try templating with alternate and deprecated templates included
# try templating with alternative and deprecated templates included
value = value % {**tmpl_dict, **alt_map, **alt_map2, **depr_map}

for old_tmpl, val in depr_map.items():
# check which deprecated templates were replaced, and issue deprecation warnings
if old_tmpl in orig_value and val in value:
new_tmpl, ver = DEPRECATED_TEMPLATES[old_tmpl]
new_tmpl, ver = DEPRECATED_EASYCONFIG_TEMPLATES[old_tmpl]
_log.deprecated(f"Easyconfig template '{old_tmpl}' is deprecated, use '{new_tmpl}' instead",
ver)
except KeyError:
_log.warning(f"Unable to resolve template value {value} with dict {tmpl_dict}")
value = raw_value # Undo "%"-escaping

for key in tmpl_dict:
if key in DEPRECATED_TEMPLATES:
new_key, ver = DEPRECATED_TEMPLATES[key]
if key in DEPRECATED_EASYCONFIG_TEMPLATES:
new_key, ver = DEPRECATED_EASYCONFIG_TEMPLATES[key]
_log.deprecated(f"Easyconfig template '{key}' is deprecated, use '{new_key}' instead", ver)

else:
Expand Down
10 changes: 5 additions & 5 deletions easybuild/framework/easyconfig/format/pyheaderconfigobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS
from easybuild.framework.easyconfig.format.format import get_format_version, EasyConfigFormat
from easybuild.framework.easyconfig.licenses import EASYCONFIG_LICENSES_DICT
from easybuild.framework.easyconfig.templates import ALTERNATE_TEMPLATE_CONSTANTS, DEPRECATED_TEMPLATE_CONSTANTS
from easybuild.framework.easyconfig.templates import ALTERNATIVE_EASYCONFIG_TEMPLATE_CONSTANTS, DEPRECATED_EASYCONFIG_TEMPLATE_CONSTANTS
from easybuild.framework.easyconfig.templates import TEMPLATE_CONSTANTS
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.configobj import ConfigObj
Expand Down Expand Up @@ -91,10 +91,10 @@ def handle_deprecated_constants(method):
"""Decorator to handle deprecated easyconfig template constants"""
def wrapper(self, key, *args, **kwargs):
"""Check whether any deprecated constants are used"""
alternate = ALTERNATE_TEMPLATE_CONSTANTS
deprecated = DEPRECATED_TEMPLATE_CONSTANTS
if key in alternate:
key = alternate[key]
alternative = ALTERNATIVE_EASYCONFIG_TEMPLATE_CONSTANTS
deprecated = DEPRECATED_EASYCONFIG_TEMPLATE_CONSTANTS
if key in alternative:
key = alternative[key]
elif key in deprecated:
depr_key = key
key, ver = deprecated[depr_key]
Expand Down
6 changes: 3 additions & 3 deletions easybuild/framework/easyconfig/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
from easybuild.tools.filetools import read_file, write_file


# alternate easyconfig parameters, and their non-deprecated equivalents
ALTERNATE_PARAMETERS = {
# alternative easyconfig parameters, and their non-deprecated equivalents
ALTERNATIVE_EASYCONFIG_PARAMETERS = {
# <new_param>: <equivalent_param>,
'build_deps': 'builddependencies',
'build_in_install_dir': 'buildininstalldir',
Expand Down Expand Up @@ -101,7 +101,7 @@
}

# deprecated easyconfig parameters, and their replacements
DEPRECATED_PARAMETERS = {
DEPRECATED_EASYCONFIG_PARAMETERS = {
# <old_param>: (<new_param>, <deprecation_version>),
}

Expand Down
12 changes: 6 additions & 6 deletions easybuild/framework/easyconfig/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
('SHLIB_EXT', get_shared_lib_ext(), 'extension for shared libraries'),
]

# alternate templates, and their equivalents
ALTERNATE_TEMPLATES = {
# alternative templates, and their equivalents
ALTERNATIVE_EASYCONFIG_TEMPLATES = {
# <new>: <equivalent_template>,
'build_dir': 'builddir',
'cuda_cc_comma_sep': 'cuda_compute_capabilities',
Expand Down Expand Up @@ -197,12 +197,12 @@
}

# deprecated templates, and their replacements
DEPRECATED_TEMPLATES = {
DEPRECATED_EASYCONFIG_TEMPLATES = {
# <old_template>: (<new_template>, <deprecation_version>),
}

# alternate template constants, and their equivalents
ALTERNATE_TEMPLATE_CONSTANTS = {
# alternative template constants, and their equivalents
ALTERNATIVE_EASYCONFIG_TEMPLATE_CONSTANTS = {
# <new_template_constant>: <equivalent_template_constant>,
'APACHE_URL': 'APACHE_SOURCE',
'BITBUCKET_GET_URL': 'BITBUCKET_SOURCE',
Expand Down Expand Up @@ -244,7 +244,7 @@
}

# deprecated template constants, and their replacements
DEPRECATED_TEMPLATE_CONSTANTS = {
DEPRECATED_EASYCONFIG_TEMPLATE_CONSTANTS = {
# <old_template_constant>: (<new_template_constant>, <deprecation_version>),
}

Expand Down
8 changes: 4 additions & 4 deletions easybuild/framework/easyconfig/tweak.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
(highest_version_ignoring_versionsuffix is not None and highest_version is not None and
LooseVersion(highest_version_ignoring_versionsuffix) > LooseVersion(highest_version))

exclude_alternate_versionsuffixes = False
exclude_alternative_versionsuffixes = False
if ignored_versionsuffix_greater:
if ignore_versionsuffixes:
highest_version = highest_version_ignoring_versionsuffix
Expand All @@ -1247,11 +1247,11 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
dep['name'], versionsuffix, [d['path'] for d in potential_version_mappings if
d['version'] == highest_version_ignoring_versionsuffix])
# exclude candidates with a different versionsuffix
exclude_alternate_versionsuffixes = True
exclude_alternative_versionsuffixes = True
else:
# If the other version suffixes are not greater, then just ignore them
exclude_alternate_versionsuffixes = True
if exclude_alternate_versionsuffixes:
exclude_alternative_versionsuffixes = True
if exclude_alternative_versionsuffixes:
potential_version_mappings = [d for d in potential_version_mappings if d['versionsuffix'] == versionsuffix]

if highest_versions_only and highest_version is not None:
Expand Down
2 changes: 1 addition & 1 deletion easybuild/toolchains/compiler/craype.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CrayPECompiler(Compiler):

COMPILER_UNIQUE_OPTS = {
'dynamic': (True, "Generate dynamically linked executable"),
'mpich-mt': (False, "Directs the driver to link in an alternate version of the Cray-MPICH library which \
'mpich-mt': (False, "Directs the driver to link in an alternative version of the Cray-MPICH library which \
provides fine-grained multi-threading support to applications that perform \
MPI operations within threaded regions."),
'optarch': (False, "Enable architecture optimizations"),
Expand Down
6 changes: 3 additions & 3 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,11 @@ def normalize_path(path):


def is_alt_pypi_url(url):
"""Determine whether specified URL is already an alternate PyPI URL, i.e. whether it contains a hash."""
"""Determine whether specified URL is already an alternative PyPI URL, i.e. whether it contains a hash."""
# example: .../packages/5b/03/e135b19fadeb9b1ccb45eac9f60ca2dc3afe72d099f6bd84e03cb131f9bf/easybuild-2.7.0.tar.gz
alt_url_regex = re.compile('/packages/[a-f0-9]{2}/[a-f0-9]{2}/[a-f0-9]{60}/[^/]+$')
res = bool(alt_url_regex.search(url))
_log.debug("Checking whether '%s' is an alternate PyPI URL using pattern '%s'...: %s",
_log.debug("Checking whether '%s' is an alternative PyPI URL using pattern '%s'...: %s",
url, alt_url_regex.pattern, res)
return res

Expand Down Expand Up @@ -638,7 +638,7 @@ def handle_starttag(self, tag, attrs):


def derive_alt_pypi_url(url):
"""Derive alternate PyPI URL for given URL."""
"""Derive alternative PyPI URL for given URL."""
alt_pypi_url = None

# example input URL: https://pypi.python.org/packages/source/e/easybuild/easybuild-2.7.0.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/toolchain/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def prepare_rpath_wrappers(self, rpath_filter_dirs=None, rpath_include_dirs=None

def handle_sysroot(self):
"""
Extra stuff to be done when alternate system root is specified via --sysroot EasyBuild configuration option.
Extra stuff to be done when alternative system root is specified via --sysroot EasyBuild configuration option.
* Update $PKG_CONFIG_PATH to include sysroot location to pkg-config files (*.pc).
"""
Expand Down
8 changes: 4 additions & 4 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_make_module_extend_modpath(self):
regex = re.compile(regex, re.M)
self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt))

# Repeat this but using an alternate envvars (instead of $HOME)
# Repeat this but using an alternative envvars (instead of $HOME)
list_of_envvars = ['SITE_INSTALLS', 'USER_INSTALLS']

build_options = {
Expand Down Expand Up @@ -1813,7 +1813,7 @@ def test_obtain_file(self):
res = eb.obtain_file(toy_tarball)
self.assertEqual(res, toy_tarball_path)

# finding a file in the alternate location works
# finding a file in the alternative location works
with self.mocked_stdout_stderr():
res = eb.obtain_file(toy_tarball, alt_location='alt_toy')
self.assertEqual(res, alt_toy_tarball_path)
Expand Down Expand Up @@ -2720,10 +2720,10 @@ def run_checks():
# no checksum issues
self.assertEqual(eb.check_checksums(), [])

# tuple of two alternate SHA256 checksums: OK
# tuple of two alternative SHA256 checksums: OK
eb.cfg['checksums'] = [
(
# two alternate checksums for toy-0.0.tar.gz
# two alternative checksums for toy-0.0.tar.gz
'a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd',
'44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc',
),
Expand Down
Loading

0 comments on commit 8d73499

Please sign in to comment.