Repository: easybuilders/easybuild-easyblocks

Issue:
Better error message when BLAS is expected in the Easyblock but the toolchain does not provide it
I tried to build SuperLU in GCCcore and got the following error:
```
$ eb SAIGE-0.35.8.8-foss-2019a-R-3.6.0.eb -Tr
== temporary log file in case of crash /scratch/branfosj-admin/eb-5y3HuT/easybuild-HPGR5T.log
== resolving dependencies ...
== processing EasyBuild easyconfig /rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-easyconfigs/easybuild/easyconfigs/s/SuperLU/SuperLU-5.2.1-GCCcore-8.2.0.eb
== building and installing SuperLU/5.2.1-GCCcore-8.2.0...
  >> installation prefix: /rds/bear-apps/devel/2019a/branfosj-eb-4/EL7/EL7-cascadelake/software/SuperLU/5.2.1-GCCcore-8.2.0
== fetching files...
  >> sources:
  >> /rds/bear-sysadmin/configmgmt/easybuild/sources/s/SuperLU/superlu_5.2.1.tar.gz [SHA256: 28fb66d6107ee66248d5cf508c79de03d0621852a0ddeba7301801d3d859f463]
== creating build dir, resetting environment...
  >> build dir: /dev/shm/build-branfosj-admin/branfosj-admin-4/SuperLU/5.2.1/GCCcore-8.2.0
== unpacking...
  >> running command:
        [started at: 2019-10-14 13:48:47]
        [output logged in /scratch/branfosj-admin/eb-5y3HuT/easybuild-run_cmd-3y3GN5.log]
        tar xzf /rds/bear-sysadmin/configmgmt/easybuild/sources/s/SuperLU/superlu_5.2.1.tar.gz
  >> command completed: exit 0, ran in < 1s
== patching...
== preparing...
  >> loading toolchain module: GCCcore/8.2.0
  >> loading modules for build dependencies:
  >>  * CMake/3.13.3-GCCcore-8.2.0
  >> (no (runtime) dependencies specified)
  >> defining build environment for GCCcore/8.2.0 toolchain
== configuring...
ERROR: Traceback (most recent call last):
  File "/rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-framework/easybuild/main.py", line 112, in build_and_install_software
    (ec_res['success'], app_log, err) = build_and_install_one(ec, init_env)
  File "/rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-framework/easybuild/framework/easyblock.py", line 3046, in build_and_install_one
    result = app.run_all_steps(run_test_cases=run_test_cases)
  File "/rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-framework/easybuild/framework/easyblock.py", line 2956, in run_all_steps
    self.run_step(step_name, step_methods)
  File "/rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-framework/easybuild/framework/easyblock.py", line 2826, in run_step
    step_method(self)()
  File "/rds/bear-apps/devel/2019a/branfosj-eb-4/src/easybuild-easyblocks/easybuild/easyblocks/s/superlu.py", line 80, in configure_step
    toolchain_blas = self.toolchain.definition().get('BLAS', None)[0]
TypeError: 'NoneType' object has no attribute '__getitem__
```

Moving SuperLU to foss fixed the issue (as per a suggestion from Boegel).


Discussion:
This is specific to the SuperLU easyblock I guess, since that where we blindly assume that the toolchain has BLAS support...

So, moving this to the easyblocks repo.

Resolving patch:
diff --git a/easybuild/easyblocks/s/superlu.py b/easybuild/easyblocks/s/superlu.py
--- a/easybuild/easyblocks/s/superlu.py
+++ b/easybuild/easyblocks/s/superlu.py
@@ -77,7 +77,12 @@ def configure_step(self):
         # Set the BLAS library to use
         # For this, use the BLA_VENDOR option from the FindBLAS module of CMake
         # Check for all possible values at https://cmake.org/cmake/help/latest/module/FindBLAS.html
-        toolchain_blas = self.toolchain.definition().get('BLAS', None)[0]
+        toolchain_blas_list = self.toolchain.definition().get('BLAS', None)
+        if toolchain_blas_list is None:
+            # This toolchain has no BLAS library
+            raise EasyBuildError("No BLAS library found in the toolchain")
+
+        toolchain_blas = toolchain_blas_list[0]
         if toolchain_blas == 'imkl':
             imkl_version = get_software_version('imkl')
             if LooseVersion(imkl_version) >= LooseVersion('10'):
@@ -99,10 +104,6 @@ def configure_step(self):
             openblas_lib = os.path.join(get_software_root('OpenBLAS'), get_software_libdir('OpenBLAS'), "libopenblas.a")
             self.cfg.update('configopts', '-DBLAS_LIBRARIES="%s;-pthread"' % openblas_lib)
 
-        elif toolchain_blas is None:
-            # This toolchain has no BLAS library
-            raise EasyBuildError("No BLAS library found in the toolchain")
-
         else:
             # This BLAS library is not supported yet
             raise EasyBuildError("BLAS library '%s' is not supported yet", toolchain_blas)


Test patch: