Hi Ben,

On 09/01/15 00:19, Ben Roberts wrote:
Hi all,


Is there a convenient way to do things so I can have both EasyBlock modules in 
place at once? I don’t suppose I could call both EB_GROMACS, and it’s not clear 
that names such as EB_GROMACS_PRE46 and EB_GROMACS_POST46 will have the desired 
effect either. Thoughts?
You can use the self.version inside an easyblock,
so you could have one easyblock that behaves differently depending on the version in the easyconfig.
See SAMtools for an example [0]

One fun (nasty?) think you can do with python is multiple inheritance, so you can have the EB_GROMACS class inherit from both configuremake and cmakemake, or maybe inherit from EB_GROMACS_PRE46 and EB_GROMACS_POST46 and in the init you could call the super depending on the version.

so something like this:

class EB_GROMACS(EB_GROMACS_PRE46, EB_GROMACS_POST46):
    def __init__(self, *args, **kwargs):
if LooseVersion(self.version) < LooseVersion(4.6):
            EB_GROMACS_PRE46.__init__(self, *args, *kwargs)
        else:
            EB_GROMACS_POST46.__init__(self, *args, *kwargs)


I'm sure there are other ways to do this, but this looks the most simple and modular at the same time to me. If the internal changes are pretty small you can do it the way samtools does it and have version checks scattered trough the easyblock.
Thanks,
Ben

Regards,
Jens Timmerman

[0] https://github.com/hpcugent/easybuild-easyblocks/blob/0dfed6cbeeeef56c4c21bc5397623cd91b606ff4/easybuild/easyblocks/s/samtools.py

Reply via email to