|
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 | 70 | from easybuild.tools.py2vs3 import OrderedDict, create_base_metaclass, string_type |
71 | | -from easybuild.tools.systemtools import check_os_dependency |
| 71 | +from easybuild.tools.systemtools import check_os_dependency, get_cpu_architecture |
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 |
@@ -1229,6 +1229,31 @@ def get_parsed_multi_deps(self): |
1229 | 1229 |
|
1230 | 1230 | return multi_deps |
1231 | 1231 |
|
| 1232 | + def find_dep_version_match(self, dep_version): |
| 1233 | + """Identify the correct version for this system from the choices provided. This returns the version to use.""" |
| 1234 | + if isinstance(dep_version, string_type): |
| 1235 | + self.log.debug("Version is already a string ('%s'), OK", dep_version) |
| 1236 | + return dep_version |
| 1237 | + elif dep_version is None: |
| 1238 | + self.log.debug("Version is None, OK") |
| 1239 | + return None |
| 1240 | + elif isinstance(dep_version, dict): |
| 1241 | + # figure out matches based on dict keys (after splitting on '=') |
| 1242 | + my_arch_key = 'arch=%s' % get_cpu_architecture() |
| 1243 | + arch_keys = [x for x in dep_version.keys() if x.startswith('arch=')] |
| 1244 | + other_keys = [x for x in dep_version.keys() if x not in arch_keys] |
| 1245 | + if other_keys: |
| 1246 | + raise EasyBuildError("Unexpected keys in version: %s. Only 'arch=' keys are supported", other_keys) |
| 1247 | + if arch_keys: |
| 1248 | + if my_arch_key in dep_version: |
| 1249 | + ver = dep_version[my_arch_key] |
| 1250 | + self.log.info("Version selected from %s using key %s: %s", dep_version, my_arch_key, ver) |
| 1251 | + return ver |
| 1252 | + else: |
| 1253 | + raise EasyBuildError("No matches for version in %s (looking for %s)", dep_version, my_arch_key) |
| 1254 | + |
| 1255 | + raise EasyBuildError("Unknown value type for version: %s", dep_version) |
| 1256 | + |
1232 | 1257 | # private method |
1233 | 1258 | def _parse_dependency(self, dep, hidden=False, build_only=False): |
1234 | 1259 | """ |
@@ -1272,6 +1297,7 @@ def _parse_dependency(self, dep, hidden=False, build_only=False): |
1272 | 1297 | # provides information on what this module represents (software name/version, install prefix, ...) |
1273 | 1298 | 'external_module_metadata': {}, |
1274 | 1299 | } |
| 1300 | + |
1275 | 1301 | if isinstance(dep, dict): |
1276 | 1302 | dependency.update(dep) |
1277 | 1303 |
|
@@ -1308,6 +1334,9 @@ def _parse_dependency(self, dep, hidden=False, build_only=False): |
1308 | 1334 | else: |
1309 | 1335 | raise EasyBuildError("Dependency %s of unsupported type: %s", dep, type(dep)) |
1310 | 1336 |
|
| 1337 | + # Find the version to use on this system |
| 1338 | + dependency['version'] = self.find_dep_version_match(dependency['version']) |
| 1339 | + |
1311 | 1340 | if dependency['external_module']: |
1312 | 1341 | # check whether the external module is hidden |
1313 | 1342 | if dependency['full_mod_name'].split('/')[-1].startswith('.'): |
|
0 commit comments