Skip to content

Commit b6daaac

Browse files
authored
Merge pull request #4069 from boegel/system_constant_tc_dep
use SYSTEM constant for dependency that uses system toolchain in dumped easyconfig
2 parents a8c0cad + f8f1019 commit b6daaac

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

easybuild/framework/easyconfig/easyconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import easybuild.tools.filetools as filetools
5151
from easybuild.base import fancylogger
5252
from easybuild.framework.easyconfig import MANDATORY
53-
from easybuild.framework.easyconfig.constants import EXTERNAL_MODULE_MARKER
53+
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS, EXTERNAL_MODULE_MARKER
5454
from easybuild.framework.easyconfig.default import DEFAULT_CONFIG
5555
from easybuild.framework.easyconfig.format.convert import Dependency
5656
from easybuild.framework.easyconfig.format.format import DEPENDENCY_PARAMETERS
@@ -1589,7 +1589,7 @@ def _parse_dependency(self, dep, hidden=False, build_only=False):
15891589

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

15941594
# two-element list/tuple value indicates custom toolchain specification
15951595
elif isinstance(tc_spec, (list, tuple,)):

easybuild/framework/easyconfig/format/one.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,19 @@ def dump_dependency(dep, toolchain, toolchain_hierarchy=None):
7676
else:
7777
# minimal spec: (name, version)
7878
tup = (dep['name'], dep['version'])
79+
res = None
7980
if all(dep['toolchain'] != subtoolchain for subtoolchain in toolchain_hierarchy):
8081
if dep[SYSTEM_TOOLCHAIN_NAME]:
81-
tup += (dep['versionsuffix'], True)
82+
# use SYSTEM constant to indicate that system toolchain should be used for this dependency
83+
res = re.sub(r'\)$', ', SYSTEM)', str(tup + (dep['versionsuffix'],)))
8284
else:
8385
tup += (dep['versionsuffix'], (dep['toolchain']['name'], dep['toolchain']['version']))
8486

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

88-
res = str(tup)
90+
if res is None:
91+
res = str(tup)
8992
return res
9093

9194

test/framework/easyconfig.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,42 @@ def test_dump(self):
20942094
if param in ec:
20952095
self.assertEqual(ec[param], dumped_ec[param])
20962096

2097+
ec_txt = textwrap.dedent("""
2098+
easyblock = 'EB_toy'
2099+
2100+
name = 'foo'
2101+
version = '0.0.1'
2102+
2103+
toolchain = {'name': 'GCC', 'version': '4.6.3'}
2104+
2105+
homepage = 'http://foo.com/'
2106+
description = "foo description"
2107+
2108+
sources = [SOURCE_TAR_GZ]
2109+
source_urls = ["http://example.com"]
2110+
2111+
dependencies = [
2112+
('toy', '0.0', '', True),
2113+
('GCC', '4.9.2', '', SYSTEM),
2114+
]
2115+
2116+
moduleclass = 'tools'
2117+
""")
2118+
test_ec = os.path.join(self.test_prefix, 'test.eb')
2119+
write_file(test_ec, ec_txt)
2120+
ec = EasyConfig(test_ec)
2121+
2122+
# verify whether SYSTEM constant is used for dependency that uses system toolchain in dumped easyconfig
2123+
dumped_ec = os.path.join(self.test_prefix, 'dumped.eb')
2124+
ec.dump(dumped_ec)
2125+
dumped_ec_txt = read_file(dumped_ec)
2126+
patterns = [
2127+
"('toy', '0.0', '', SYSTEM)",
2128+
"('GCC', '4.9.2', '', SYSTEM)",
2129+
]
2130+
for pattern in patterns:
2131+
self.assertTrue(pattern in dumped_ec_txt, "Pattern '%s' should be found in: %s" % (pattern, dumped_ec_txt))
2132+
20972133
def test_toolchain_hierarchy_aware_dump(self):
20982134
"""Test that EasyConfig's dump() method is aware of the toolchain hierarchy."""
20992135
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')

0 commit comments

Comments
 (0)