|
67 | 67 | from easybuild.tools.module_naming_scheme.utilities import avail_module_naming_schemes, det_full_ec_version |
68 | 68 | from easybuild.tools.module_naming_scheme.utilities import det_hidden_modname, is_valid_module_name |
69 | 69 | from easybuild.tools.modules import modules_tool |
70 | | -from easybuild.tools.py2vs3 import OrderedDict, string_type |
71 | | -from easybuild.tools.systemtools import check_os_dependency |
| 70 | +from easybuild.tools.py2vs3 import OrderedDict, create_base_metaclass, string_type |
| 71 | +from easybuild.tools.systemtools import check_os_dependency, pick_dep_version |
72 | 72 | from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME, is_system_toolchain |
73 | 73 | from easybuild.tools.toolchain.toolchain import TOOLCHAIN_CAPABILITIES, TOOLCHAIN_CAPABILITY_CUDA |
74 | 74 | from easybuild.tools.toolchain.utilities import get_toolchain, search_toolchain |
@@ -410,7 +410,7 @@ def __init__(self, path, extra_options=None, build_specs=None, validate=True, hi |
410 | 410 | if rawtxt is None: |
411 | 411 | self.path = path |
412 | 412 | self.rawtxt = read_file(path) |
413 | | - self.log.debug("Raw contents from supplied easyconfig file %s: %s" % (path, self.rawtxt)) |
| 413 | + self.log.debug("Raw contents from supplied easyconfig file %s: %s", path, self.rawtxt) |
414 | 414 | else: |
415 | 415 | self.rawtxt = rawtxt |
416 | 416 | self.log.debug("Supplied raw easyconfig contents: %s" % self.rawtxt) |
@@ -497,6 +497,8 @@ def __init__(self, path, extra_options=None, build_specs=None, validate=True, hi |
497 | 497 | self.short_mod_name = mns.det_short_module_name(self) |
498 | 498 | self.mod_subdir = mns.det_module_subdir(self) |
499 | 499 |
|
| 500 | + self.set_default_module = False |
| 501 | + |
500 | 502 | self.software_license = None |
501 | 503 |
|
502 | 504 | def filename(self): |
@@ -530,12 +532,15 @@ def extend_params(self, extra, overwrite=True): |
530 | 532 | self.mandatory.append(key) |
531 | 533 | self.log.debug("Updated list of mandatory easyconfig parameters: %s", self.mandatory) |
532 | 534 |
|
533 | | - def copy(self): |
| 535 | + def copy(self, validate=None): |
534 | 536 | """ |
535 | 537 | Return a copy of this EasyConfig instance. |
536 | 538 | """ |
| 539 | + if validate is None: |
| 540 | + validate = self.validation |
| 541 | + |
537 | 542 | # create a new EasyConfig instance |
538 | | - ec = EasyConfig(self.path, validate=self.validation, hidden=self.hidden, rawtxt=self.rawtxt) |
| 543 | + ec = EasyConfig(self.path, validate=validate, hidden=self.hidden, rawtxt=self.rawtxt) |
539 | 544 | # take a copy of the actual config dictionary (which already contains the extra options) |
540 | 545 | ec._config = copy.deepcopy(self._config) |
541 | 546 | # since rawtxt is defined, self.path may not get inherited, make sure it does |
@@ -601,7 +606,7 @@ def parse(self): |
601 | 606 | type(self.build_specs)) |
602 | 607 | self.log.debug("Obtained specs dict %s" % arg_specs) |
603 | 608 |
|
604 | | - self.log.info("Parsing easyconfig file %s with rawcontent: %s" % (self.path, self.rawtxt)) |
| 609 | + self.log.info("Parsing easyconfig file %s with rawcontent: %s", self.path, self.rawtxt) |
605 | 610 | self.parser.set_specifications(arg_specs) |
606 | 611 | local_vars = self.parser.get_config_dict() |
607 | 612 | self.log.debug("Parsed easyconfig as a dictionary: %s" % local_vars) |
@@ -1269,6 +1274,7 @@ def _parse_dependency(self, dep, hidden=False, build_only=False): |
1269 | 1274 | # provides information on what this module represents (software name/version, install prefix, ...) |
1270 | 1275 | 'external_module_metadata': {}, |
1271 | 1276 | } |
| 1277 | + |
1272 | 1278 | if isinstance(dep, dict): |
1273 | 1279 | dependency.update(dep) |
1274 | 1280 |
|
@@ -1305,6 +1311,9 @@ def _parse_dependency(self, dep, hidden=False, build_only=False): |
1305 | 1311 | else: |
1306 | 1312 | raise EasyBuildError("Dependency %s of unsupported type: %s", dep, type(dep)) |
1307 | 1313 |
|
| 1314 | + # Find the version to use on this system |
| 1315 | + dependency['version'] = pick_dep_version(dependency['version']) |
| 1316 | + |
1308 | 1317 | if dependency['external_module']: |
1309 | 1318 | # check whether the external module is hidden |
1310 | 1319 | if dependency['full_mod_name'].split('/')[-1].startswith('.'): |
@@ -1482,6 +1491,10 @@ def __getitem__(self, key): |
1482 | 1491 |
|
1483 | 1492 | return value |
1484 | 1493 |
|
| 1494 | + def is_mandatory_param(self, key): |
| 1495 | + """Check whether specified easyconfig parameter is mandatory.""" |
| 1496 | + return key in self.mandatory |
| 1497 | + |
1485 | 1498 | def get_ref(self, key): |
1486 | 1499 | """ |
1487 | 1500 | Obtain reference to original/untemplated value of specified easyconfig parameter |
@@ -2209,10 +2222,12 @@ def fix_deprecated_easyconfigs(paths): |
2209 | 2222 | print_msg("\nAll done! Fixed %d easyconfigs (out of %d found).\n", fixed_cnt, cnt, prefix=False) |
2210 | 2223 |
|
2211 | 2224 |
|
2212 | | -class ActiveMNS(object): |
2213 | | - """Wrapper class for active module naming scheme.""" |
| 2225 | +# singleton metaclass: only one instance is created |
| 2226 | +BaseActiveMNS = create_base_metaclass('BaseActiveMNS', Singleton, object) |
2214 | 2227 |
|
2215 | | - __metaclass__ = Singleton |
| 2228 | + |
| 2229 | +class ActiveMNS(BaseActiveMNS): |
| 2230 | + """Wrapper class for active module naming scheme.""" |
2216 | 2231 |
|
2217 | 2232 | def __init__(self, *args, **kwargs): |
2218 | 2233 | """Initialize logger.""" |
|
0 commit comments