easyblock = 'Bundle'

name = 'ELIC_R'
version = '1'

homepage = 'https://gogs.elic.ucl.ac.be'
description = """This repo provides additional Python and R extensions for ELIC ecosystem."""

toolchain = {'name': 'foss', 'version': '2021b'}

dependencies = [
    ('R', '4.1.0'),
    ('GDAL', '3.3.0'),
    ('PostgreSQL', '13.3'),
]

exts_default_options = {
    'source_urls': [
        'https://cran.r-project.org/src/contrib/Archive/%(name)s',  # package archive
        'https://cran.r-project.org/src/contrib/',  # current version of packages
        'https://cran.freestatistics.org/src/contrib',  # mirror alternative for current packages
    ],
    'source_tmpl': '%(name)s_%(version)s.tar.gz'
}

exts_defaultclass = 'RPackage'
exts_filter = ("R -q --no-save", "library(%(ext_name)s)")

modextrapaths = {'R_LIBS': ''}

postinstallcmds = [
    "cd %(installdir)s && " +
    'Rscript -e "library(remotes); install_github(\'myllym/GET\', lib=\'%(installdir)s\')" && ' +
    'Rscript -e "install.packages(c(\'rgdal\', \'gdalUtils\', \'ncdf4\', \'RPostgreSQL\', \'RPostgres\'), repos=\'https://www.freestatistics.org/cran/\', lib=\'%(installdir)s\')"'
]

sanity_check_paths = {
    'files': [],
    'dirs': ['RPostgreSQL'],
}

moduleclass = 'numlib'
