@@ -421,6 +421,37 @@ def pre_fetch_hook(self, *args, **kwargs):
421421 if cpu_target == CPU_TARGET_ZEN4 :
422422 pre_fetch_hook_zen4_gcccore1220 (self , * args , ** kwargs )
423423
424+ # Always check the software installation path
425+ pre_fetch_hook_check_installation_path (self , * args , ** kwargs )
426+
427+
428+ # Check the installation path so we verify that accelerator software always gets installed into the correct location
429+ def pre_fetch_hook_check_installation_path (self , * args , ** kwargs ):
430+ # When we know the CUDA status, we will need to verify the installation path
431+ # if we are doing an EESSI or host_injections installation
432+ accelerator_deps = ['CUDA' ]
433+ strict_eessi_installation = (
434+ bool (re .search (EESSI_INSTALLATION_REGEX , self .installdir )) or
435+ self .installdir .startswith (HOST_INJECTIONS_LOCATION ))
436+ if strict_eessi_installation :
437+ dependency_names = self .cfg .dependency_names ()
438+ if self .cfg .name in accelerator_deps or any (dep in dependency_names for dep in accelerator_deps ):
439+ # Make sure the path is an accelerator location
440+ if "/accel/" not in self .installdir :
441+ raise EasyBuildError (
442+ f"It seems you are trying to install an accelerator package { self .cfg .name } into a "
443+ f"non-accelerator location { self .installdir } . You need to reconfigure your installation to target "
444+ "the correct location."
445+ )
446+ else :
447+ # If we don't have an accelerator dependency then we should be in a CPU installation path
448+ if "/accel/" in self .installdir :
449+ raise EasyBuildError (
450+ f"It seems you are trying to install a CPU-only package { self .cfg .name } into accelerator location "
451+ f"{ self .installdir } . If this is a dependency of the package you are really interested in you will "
452+ "need to first install the CPU-only dependencies of that package."
453+ )
454+
424455
425456def pre_fetch_hook_zen4_gcccore1220 (self , * args , ** kwargs ):
426457 """Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4.
0 commit comments