Skip to content

Commit b9ca155

Browse files
committed
update eb hooks
1 parent c58d176 commit b9ca155

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

eb_hooks.py

+43-20
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
from easybuild.tools.systemtools import AARCH64, POWER, X86_64, get_cpu_architecture, get_cpu_features
1212
from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC
1313

14+
# prefer importing LooseVersion from easybuild.tools, but fall back to distutils
15+
# in case EasyBuild <= 4.7.0 is used
16+
try:
17+
from easybuild.tools import LooseVersion
18+
except ImportError:
19+
from distutils.version import LooseVersion
20+
21+
1422
EESSI_RPATH_OVERRIDE_ATTR = 'orig_rpath_override_dirs'
1523

1624

@@ -56,11 +64,11 @@ def parse_hook(ec, *args, **kwargs):
5664
PARSE_HOOKS[ec.name](ec, eprefix)
5765

5866

59-
def pre_configure_hook(self, *args, **kwargs):
60-
"""Main pre-configure hook: trigger custom functions based on software name."""
61-
62-
if self.name in PRE_CONFIGURE_HOOKS:
63-
PRE_CONFIGURE_HOOKS[self.name](self, *args, **kwargs)
67+
#def pre_configure_hook(self, *args, **kwargs):
68+
# """Main pre-configure hook: trigger custom functions based on software name."""
69+
#
70+
# if self.name in PRE_CONFIGURE_HOOKS:
71+
# PRE_CONFIGURE_HOOKS[self.name](self, *args, **kwargs)
6472

6573

6674
def pre_prepare_hook(self, *args, **kwargs):
@@ -91,10 +99,11 @@ def pre_prepare_hook(self, *args, **kwargs):
9199
mpi_family, rpath_override_dirs)
92100

93101

94-
def gcc_postprepare(self, *args, **kwargs):
102+
def post_prepare_hook_gcc_prefixed_ld_rpath_wrapper(self, *args, **kwargs):
95103
"""
96104
Post-configure hook for GCCcore:
97-
- copy RPATH wrapper script for linker commands to also have a wrapper in place with system type prefix like 'x86_64-pc-linux-gnu'
105+
- copy RPATH wrapper script for linker commands to also have a wrapper in
106+
place with system type prefix like 'x86_64-pc-linux-gnu'
98107
"""
99108
if self.name == 'GCCcore':
100109
config_guess = obtain_config_guess()
@@ -121,6 +130,7 @@ def gcc_postprepare(self, *args, **kwargs):
121130
else:
122131
raise EasyBuildError("GCCcore-specific hook triggered for non-GCCcore easyconfig?!")
123132

133+
124134
def post_prepare_hook(self, *args, **kwargs):
125135
"""Main post-prepare hook: trigger custom functions."""
126136

@@ -134,7 +144,7 @@ def post_prepare_hook(self, *args, **kwargs):
134144
POST_PREPARE_HOOKS[self.name](self, *args, **kwargs)
135145

136146

137-
def cgal_toolchainopts_precise(ec, eprefix):
147+
def parse_hook_cgal_toolchainopts_precise(ec, eprefix):
138148
"""Enable 'precise' rather than 'strict' toolchain option for CGAL on POWER."""
139149
if ec.name == 'CGAL':
140150
if get_cpu_architecture() == POWER:
@@ -147,7 +157,7 @@ def cgal_toolchainopts_precise(ec, eprefix):
147157
raise EasyBuildError("CGAL-specific hook triggered for non-CGAL easyconfig?!")
148158

149159

150-
def fontconfig_add_fonts(ec, eprefix):
160+
def parse_hook_fontconfig_add_fonts(ec, eprefix):
151161
"""Inject --with-add-fonts configure option for fontconfig."""
152162
if ec.name == 'fontconfig':
153163
# make fontconfig aware of fonts included with compat layer
@@ -158,7 +168,7 @@ def fontconfig_add_fonts(ec, eprefix):
158168
raise EasyBuildError("fontconfig-specific hook triggered for non-fontconfig easyconfig?!")
159169

160170

161-
def ucx_eprefix(ec, eprefix):
171+
def parse_hook_ucx_eprefix(ec, eprefix):
162172
"""Make UCX aware of compatibility layer via additional configuration options."""
163173
if ec.name == 'UCX':
164174
ec.update('configopts', '--with-sysroot=%s' % eprefix)
@@ -174,7 +184,19 @@ def pre_configure_hook(self, *args, **kwargs):
174184
PRE_CONFIGURE_HOOKS[self.name](self, *args, **kwargs)
175185

176186

177-
def libfabric_disable_psm3_x86_64_generic(self, *args, **kwargs):
187+
def pre_configure_hook_openblas_optarch_generic(self, *args, **kwargs):
188+
"""
189+
Pre-configure hook for OpenBLAS: add DYNAMIC_ARCH=1 to build/test/install options when using --optarch=GENERIC
190+
"""
191+
if self.name == 'OpenBLAS':
192+
if build_option('optarch') == OPTARCH_GENERIC:
193+
for step in ('build', 'test', 'install'):
194+
self.cfg.update(f'{step}opts', "DYNAMIC_ARCH=1")
195+
else:
196+
raise EasyBuildError("OpenBLAS-specific hook triggered for non-OpenBLAS easyconfig?!")
197+
198+
199+
def pre_configure_hook_libfabric_disable_psm3_x86_64_generic(self, *args, **kwargs):
178200
"""Add --disable-psm3 to libfabric configure options when building with --optarch=GENERIC on x86_64."""
179201
if self.name == 'libfabric':
180202
if get_cpu_architecture() == X86_64:
@@ -187,7 +209,7 @@ def libfabric_disable_psm3_x86_64_generic(self, *args, **kwargs):
187209
raise EasyBuildError("libfabric-specific hook triggered for non-libfabric easyconfig?!")
188210

189211

190-
def metabat_preconfigure(self, *args, **kwargs):
212+
def pre_configure_hook_metabat_filtered_zlib_dep(self, *args, **kwargs):
191213
"""
192214
Pre-configure hook for MetaBAT:
193215
- take into account that zlib is a filtered dependency,
@@ -201,7 +223,7 @@ def metabat_preconfigure(self, *args, **kwargs):
201223
raise EasyBuildError("MetaBAT-specific hook triggered for non-MetaBAT easyconfig?!")
202224

203225

204-
def wrf_preconfigure(self, *args, **kwargs):
226+
def pre_configure_hook_wrf_aarch64(self, *args, **kwargs):
205227
"""
206228
Pre-configure hook for WRF:
207229
- patch arch/configure_new.defaults so building WRF with foss toolchain works on aarch64
@@ -217,17 +239,18 @@ def wrf_preconfigure(self, *args, **kwargs):
217239

218240

219241
PARSE_HOOKS = {
220-
'CGAL': cgal_toolchainopts_precise,
221-
'fontconfig': fontconfig_add_fonts,
222-
'UCX': ucx_eprefix,
242+
'CGAL': parse_hook_cgal_toolchainopts_precise,
243+
'fontconfig': parse_hook_fontconfig_add_fonts,
244+
'UCX': parse_hook_ucx_eprefix,
223245
}
224246

225247
POST_PREPARE_HOOKS = {
226-
'GCCcore': gcc_postprepare,
248+
'GCCcore': post_prepare_hook_gcc_prefixed_ld_rpath_wrapper,
227249
}
228250

229251
PRE_CONFIGURE_HOOKS = {
230-
'libfabric': libfabric_disable_psm3_x86_64_generic,
231-
'MetaBAT': metabat_preconfigure,
232-
'WRF': wrf_preconfigure,
252+
'libfabric': pre_configure_hook_libfabric_disable_psm3_x86_64_generic,
253+
'MetaBAT': pre_configure_hook_metabat_filtered_zlib_dep,
254+
'OpenBLAS': pre_configure_hook_openblas_optarch_generic,
255+
'WRF': pre_configure_hook_wrf_aarch64,
233256
}

0 commit comments

Comments
 (0)