easyblock = 'ConfigureMake'

name = 'worker'
version = '1.6.7'

homepage = 'https://github.com/gjbex/worker'
description = """The Worker framework has been developed to help deal with parameter exploration experiments
 that would otherwise result in many jobs, forcing the user resort to scripting to retain her sanity;
 see also https://vscentrum.be/neutral/documentation/cluster-doc/running-jobs/worker-framework."""

toolchain = {'name': 'dummy', 'version': ''}

source_urls = ['https://github.com/gjbex/worker/archive/']
sources = ['%(version)s.tar.gz']
checksums = ['350ffa36c792c5733ae202e76cc266648fca1311a835e9d73c98ed4f13a6835f']

tcname = 'intel'
tcver = '2016b'
builddependencies = [(tcname, tcver)]
versionsuffix = '-%s-%s' % (tcname, tcver)

exts_defaultclass = 'PerlModule'

exts_list = [
    ('Config::General', '2.61', {
        'source_tmpl': 'Config-General-2.61.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/T/TL/TLINDEN'],
        'checksums': [
            '379a160ddac33c02045d2b7e20b37ca9b155722ce20374f9f245e519f7d7a6ca',  # Config-General-2.61.tar.gz
        ],
    }),
    ('IO::Stringy', '2.111', {
        'source_tmpl': 'IO-stringy-2.111.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/D/DS/DSKOLL'],
        'checksums': [
            '8c67fd6608c3c4e74f7324f1404a856c331dbf48d9deda6aaa8296ea41bf199d',  # IO-stringy-2.111.tar.gz
        ],
    }),
    ('Text::CSV', '1.33', {
        'source_tmpl': 'Text-CSV-1.33.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/M/MA/MAKAMAKA'],
        'checksums': [
            '9c5b8fb9baffd58f02ed2b3f0b6d9a6454198f18a80e7f3a049680ddbdb24115',  # Text-CSV-1.33.tar.gz
        ],
    }),
    ('DBI', '1.636', {
        'source_tmpl': 'DBI-1.636.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/T/TI/TIMB'],
        'checksums': [
            '8f7ddce97c04b4b7a000e65e5d05f679c964d62c8b02c94c1a7d815bb2dd676c',  # DBI-1.636.tar.gz
        ],
    }),
    ('DBD::SQLite', '1.50', {
        'source_tmpl': 'DBD-SQLite-1.50.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI'],
        'checksums': [
            '3ac513ab73944fd7d4b672e1fe885dc522b6369d38f46a68e67e0045bf159ce1',  # DBD-SQLite-1.50.tar.gz
        ],
    }),
    ('Date::Language', '2.30', {
        'source_tmpl': 'TimeDate-2.30.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/G/GB/GBARR'],
        'checksums': [
            '75bd254871cb5853a6aa0403ac0be270cdd75c9d1b6639f18ecba63c15298e86',  # TimeDate-2.30.tar.gz
        ],
    }),
    ('Template', '2.27', {
        'source_tmpl': 'Template-Toolkit-%(version)s.tar.gz',
        'source_urls': ['https://cpan.metacpan.org/authors/id/A/AB/ABW'],
        'checksums': [
            '1311a403264d0134c585af0309ff2a9d5074b8ece23ece5660d31ec96bf2c6dc',  # Template-Toolkit-2.27.tar.gz
        ],
    }),
]

modextrapaths = {
    'PERL5LIB': ['share/perl5', 'lib64/perl5'],
}

# adjust worker configuration file
# note: tweak this to your local setup
postinstallcmds = [
    'sed -i "s/ cores_per_node = .*/ cores_per_node = 16/g" %(installdir)s/conf/worker.conf',
    'sed -i "s@ qsub = .*@ qsub = `which qsub`@g" %(installdir)s/conf/worker.conf',
    'sed -i "s/ email = .*/ email = hpc-support@example.com/g" %(installdir)s/conf/worker.conf',
    'sed -i "s/ unload_modules = .*/ unload_modules = intel/g" %(installdir)s/conf/worker.conf',
    'sed -i "s@ mpi_module = .*@ mpi_module = %s/%s@g" %%(installdir)s/conf/worker.conf' % (tcname, tcver),
    'sed -i "s@ module_path = .*@ module_path = %(installdir)s/../../../modules/all@g" %(installdir)s/conf/worker.conf',
]

sanity_check_paths = {
    'files': ['bin/%s' % x for x in [
        'dbilogstrip',
        'dbiprof',
        'dbiproxy',
        'tpage',
        'ttree',
        'wcat',
        'wconvert',
        'wload',
        'worker',
        'wreduce',
        'wresume',
        'wsub',
        'wsummarize',
    ]],
    'dirs': ['lib/perl', 'lib/tt', 'lib64/perl5'],
}

moduleclass = 'tools'
