Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SYSTEM constant for dependency that uses system toolchain in dumped easyconfig #4069

Merged
merged 2 commits into from Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions easybuild/framework/easyconfig/easyconfig.py
Expand Up @@ -50,7 +50,7 @@
import easybuild.tools.filetools as filetools
from easybuild.base import fancylogger
from easybuild.framework.easyconfig import MANDATORY
from easybuild.framework.easyconfig.constants import EXTERNAL_MODULE_MARKER
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS, EXTERNAL_MODULE_MARKER
from easybuild.framework.easyconfig.default import DEFAULT_CONFIG
from easybuild.framework.easyconfig.format.convert import Dependency
from easybuild.framework.easyconfig.format.format import DEPENDENCY_PARAMETERS
Expand Down Expand Up @@ -1589,7 +1589,7 @@ def _parse_dependency(self, dep, hidden=False, build_only=False):

# (true) boolean value simply indicates that a system toolchain is used
elif isinstance(tc_spec, bool) and tc_spec:
tc = {'name': SYSTEM_TOOLCHAIN_NAME, 'version': ''}
tc = EASYCONFIG_CONSTANTS['SYSTEM'][0]

# two-element list/tuple value indicates custom toolchain specification
elif isinstance(tc_spec, (list, tuple,)):
Expand Down
7 changes: 5 additions & 2 deletions easybuild/framework/easyconfig/format/one.py
Expand Up @@ -76,16 +76,19 @@ def dump_dependency(dep, toolchain, toolchain_hierarchy=None):
else:
# minimal spec: (name, version)
tup = (dep['name'], dep['version'])
res = None
if all(dep['toolchain'] != subtoolchain for subtoolchain in toolchain_hierarchy):
if dep[SYSTEM_TOOLCHAIN_NAME]:
tup += (dep['versionsuffix'], True)
# use SYSTEM constant to indicate that system toolchain should be used for this dependency
res = re.sub(r'\)$', ', SYSTEM)', str(tup + (dep['versionsuffix'],)))
else:
tup += (dep['versionsuffix'], (dep['toolchain']['name'], dep['toolchain']['version']))

elif dep['versionsuffix']:
tup += (dep['versionsuffix'],)

res = str(tup)
if res is None:
res = str(tup)
return res


Expand Down
36 changes: 36 additions & 0 deletions test/framework/easyconfig.py
Expand Up @@ -2094,6 +2094,42 @@ def test_dump(self):
if param in ec:
self.assertEqual(ec[param], dumped_ec[param])

ec_txt = textwrap.dedent("""
easyblock = 'EB_toy'

name = 'foo'
version = '0.0.1'

toolchain = {'name': 'GCC', 'version': '4.6.3'}

homepage = 'http://foo.com/'
description = "foo description"

sources = [SOURCE_TAR_GZ]
source_urls = ["http://example.com"]

dependencies = [
('toy', '0.0', '', True),
Micket marked this conversation as resolved.
Show resolved Hide resolved
('GCC', '4.9.2', '', SYSTEM),
]

moduleclass = 'tools'
""")
test_ec = os.path.join(self.test_prefix, 'test.eb')
write_file(test_ec, ec_txt)
ec = EasyConfig(test_ec)

# verify whether SYSTEM constant is used for dependency that uses system toolchain in dumped easyconfig
dumped_ec = os.path.join(self.test_prefix, 'dumped.eb')
ec.dump(dumped_ec)
dumped_ec_txt = read_file(dumped_ec)
patterns = [
"('toy', '0.0', '', SYSTEM)",
"('GCC', '4.9.2', '', SYSTEM)",
]
for pattern in patterns:
self.assertTrue(pattern in dumped_ec_txt, "Pattern '%s' should be found in: %s" % (pattern, dumped_ec_txt))

def test_toolchain_hierarchy_aware_dump(self):
"""Test that EasyConfig's dump() method is aware of the toolchain hierarchy."""
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
Expand Down