|
61 | 61 | from easybuild.framework.easyconfig.style import MAX_LINE_LENGTH |
62 | 62 | from easybuild.framework.easyconfig.tools import get_paths_for |
63 | 63 | from easybuild.framework.easyconfig.templates import TEMPLATE_NAMES_EASYBLOCK_RUN_STEP, template_constant_dict |
64 | | -from easybuild.framework.extension import resolve_exts_filter_template |
| 64 | +from easybuild.framework.extension import Extension, resolve_exts_filter_template |
65 | 65 | from easybuild.tools import config, run |
66 | 66 | from easybuild.tools.build_details import get_build_stats |
67 | 67 | from easybuild.tools.build_log import EasyBuildError, dry_run_msg, dry_run_warning, dry_run_set_dirs |
@@ -540,6 +540,10 @@ def fetch_extension_sources(self, skip_checksums=False): |
540 | 540 | 'options': ext_options, |
541 | 541 | } |
542 | 542 |
|
| 543 | + # if a particular easyblock is specified, make sure it's used |
| 544 | + # (this is picked up by init_ext_instances) |
| 545 | + ext_src['easyblock'] = ext_options.get('easyblock', None) |
| 546 | + |
543 | 547 | # construct dictionary with template values; |
544 | 548 | # inherited from parent, except for name/version templates which are specific to this extension |
545 | 549 | template_values = copy.deepcopy(self.cfg.template_values) |
@@ -2295,18 +2299,31 @@ def init_ext_instances(self): |
2295 | 2299 | ext_name = ext['name'] |
2296 | 2300 | self.log.debug("Creating class instance for extension %s...", ext_name) |
2297 | 2301 |
|
| 2302 | + # if a specific easyblock is specified for this extension, honor it; |
| 2303 | + # just passing this to get_easyblock_class is sufficient |
| 2304 | + easyblock = ext.get('easyblock', None) |
| 2305 | + if easyblock: |
| 2306 | + class_name = easyblock |
| 2307 | + mod_path = get_module_path(class_name) |
| 2308 | + else: |
| 2309 | + class_name = encode_class_name(ext_name) |
| 2310 | + mod_path = get_module_path(class_name, generic=False) |
| 2311 | + |
2298 | 2312 | cls, inst = None, None |
2299 | | - class_name = encode_class_name(ext_name) |
2300 | | - mod_path = get_module_path(class_name, generic=False) |
2301 | 2313 |
|
2302 | | - # try instantiating extension-specific class |
| 2314 | + # try instantiating extension-specific class, or honor specified easyblock |
2303 | 2315 | try: |
2304 | 2316 | # no error when importing class fails, in case we run into an existing easyblock |
2305 | 2317 | # with a similar name (e.g., Perl Extension 'GO' vs 'Go' for which 'EB_Go' is available) |
2306 | | - cls = get_easyblock_class(None, name=ext_name, error_on_failed_import=False, |
| 2318 | + cls = get_easyblock_class(easyblock, name=ext_name, error_on_failed_import=False, |
2307 | 2319 | error_on_missing_easyblock=False) |
| 2320 | + |
2308 | 2321 | self.log.debug("Obtained class %s for extension %s", cls, ext_name) |
2309 | 2322 | if cls is not None: |
| 2323 | + # make sure that this easyblock can be used to install extensions |
| 2324 | + if not issubclass(cls, Extension): |
| 2325 | + raise EasyBuildError("%s easyblock can not be used to install extensions!", cls.__name__) |
| 2326 | + |
2310 | 2327 | inst = cls(self, ext) |
2311 | 2328 | except (ImportError, NameError) as err: |
2312 | 2329 | self.log.debug("Failed to use extension-specific class for extension %s: %s", ext_name, err) |
|
0 commit comments