Skip to content

Commit

Permalink
Merge pull request #4069 from boegel/system_constant_tc_dep
Browse files Browse the repository at this point in the history
use SYSTEM constant for dependency that uses system toolchain in dumped easyconfig
  • Loading branch information
Micket committed Aug 26, 2022
2 parents a8c0cad + f8f1019 commit b6daaac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
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),
('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

0 comments on commit b6daaac

Please sign in to comment.