Going Deeper into EasyBuild: EasyBlocks
Overview
When easyconfig (*.eb file) modifications are not sufficient to install a new software or new software version using EasyBuild, one may need to modify the underlying EasyBlock code. This page describes some of the details of that process.
What is an EasyBlock?
An EasyBlock is a python file that contains instructions for EasyBuild to install a software in greater detail. There are both "generic" and software-specific easyblocks. The generic easyblocks contain general instructions that may be used for many packages. Some packages require special instructions, and so a special easyblock is provided for that software, instead of a generic one. The easyblock that is utilized by a software can be identified by the "easyblock=" parameter in its easyconfig file. If an easyblock is not specified in the easyconfig, EasyBuild will attempt to choose the correct easyblock for it, based on the software's name. (e.g. EB will use the "trilinos.py" easyblock for the Trilinos software). For more details see the EasyBuild Docmentation:
Step 1: Obtain an Existing Easyblock for a Template
The simplest way to develop a new easyblock is to start with an existing one. One may browse and download easyblock files from the easybuild-easyblocks Github page.
If one is creating an easyconfig for a new software, starting with one of the generic easyblocks may be a good choice. If one is attempting to install a newer version of a software which already has old versions available in EasyBuild, check to see if it has a software-specific easyblock, and start from there.
Step 2: Changing the EasyBlock Name
Once an existing easyblock is downloaded, one may want to change the name of the new easyblock. To do this, one must change both the name of the easyblock *.py file, and also change the name of the python class within it. For example, when changing the name of the "trilinos" easyblock to "trilinos_mod". The name of the class within the easyblock must be "EB_trilinos_mod" and the name of the easyblock *.py file itself must also be trilinos_mod.py. (the capitalization does not need to match)
Before: Filename: trilinos.py
inside the file:
After: Filename: trilinos_mod.py
inside the file:
Now the body of the easyblock may be edited as needed.
Step 3: Using the new EasyBlock File
To make sure your new easyconfig file utilizes the modified easyblock, the following must be done:
The easyblock must be specified in the easyconfig, using the "easyblock = " option. The "EB_" prefix of the easyblock's python class name must be included in this parameter, (although generic easyblocks do not have an "EB_" prefix, see: Implementing EasyBlocks) as shown below for the Trilinos example.
Next, the modified easyblock file must be specified in the "eb" command, using the "--include-easyblocks=<path/to/modified/easyblock>" option, as shown below:
eb --robot --include-easyblocks=./easyblock/trilinos_mod.py --dry-run Trilinos-13.2.0-foss-2020b-Python-3.8.6.eb
To simply check if the new easyblock is recognized, one may use the "--list-easyblocks" option, and find the modified easyblock among the names of the known easyblocks:
eb --robot --include-easyblocks=./easyblock/trilinos_mod.py --list-easyblocks
Conclusion
You are now ready to begin easyblock development. Good Luck! If your modified easyblock works, consider submitting it to the EasyBuild repository for others to use! (See: https://docs.easybuild.io/en/latest/Contributing.html#how-to-contribute )