diff --git a/eb_hooks.py b/eb_hooks.py index acbe6cab22..482ade4c20 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -422,6 +422,37 @@ def pre_fetch_hook(self, *args, **kwargs): if cpu_target == CPU_TARGET_ZEN4: pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs) + # Always check the software installation path + pre_fetch_hook_check_installation_path(self, *args, **kwargs) + + +# Check the installation path so we verify that accelerator software always gets installed into the correct location +def pre_fetch_hook_check_installation_path(self, *args, **kwargs): + # When we know the CUDA status, we will need to verify the installation path + # if we are doing an EESSI or host_injections installation + accelerator_deps = ['CUDA'] + strict_eessi_installation = ( + bool(re.search(EESSI_INSTALLATION_REGEX, self.installdir)) or + self.installdir.startswith(HOST_INJECTIONS_LOCATION)) + if strict_eessi_installation: + dependency_names = self.cfg.dependency_names() + if self.cfg.name in accelerator_deps or any(dep in dependency_names for dep in accelerator_deps): + # Make sure the path is an accelerator location + if "/accel/" not in self.installdir: + raise EasyBuildError( + f"It seems you are trying to install an accelerator package {self.cfg.name} into a " + f"non-accelerator location {self.installdir}. You need to reconfigure your installation to target " + "the correct location." + ) + else: + # If we don't have an accelerator dependency then we should be in a CPU installation path + if "/accel/" in self.installdir: + raise EasyBuildError( + f"It seems you are trying to install a CPU-only package {self.cfg.name} into accelerator location " + f"{self.installdir}. If this is a dependency of the package you are really interested in you will " + "need to first install the CPU-only dependencies of that package." + ) + def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): """Use --force --module-only if building a foss-2022b-based EasyConfig for Zen4.