From 98d7067a4594ab49665fb1b2763c886da3efd242 Mon Sep 17 00:00:00 2001 From: Samuel Moors Date: Sun, 30 Jan 2022 18:05:13 +0100 Subject: [PATCH 1/3] add custom easyblock for reticulate R package --- easybuild/easyblocks/r/reticulate.py | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 easybuild/easyblocks/r/reticulate.py diff --git a/easybuild/easyblocks/r/reticulate.py b/easybuild/easyblocks/r/reticulate.py new file mode 100644 index 00000000000..1dbb14e415e --- /dev/null +++ b/easybuild/easyblocks/r/reticulate.py @@ -0,0 +1,55 @@ +## +# Copyright 2009-2021 Ghent University +# +# This file is part of EasyBuild, +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), +# with support of Ghent University (http://ugent.be/hpc), +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). +# +# https://github.com/easybuilders/easybuild +# +# EasyBuild is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation v2. +# +# EasyBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with EasyBuild. If not, see . +## +""" +EasyBuild support for building and installing reticulate R package, implemented as an easyblock + +@author: Samuel Moors (Vrije Universiteit Brussel +""" +import os + +from easybuild.easyblocks.generic.rpackage import RPackage +from easybuild.tools.build_log import EasyBuildError +from easybuild.tools.modules import get_software_root + + +class EB_reticulate(RPackage): + """Support for installing the reticulate R package.""" + + def make_module_extra_ext_only(self): + """Add extra environment variables to modulefile""" + + txt = super(EB_reticulate, self).make_module_extra_ext_only() + + pythonroot = get_software_root('Python') + if pythonroot: + # make sure EB-provided Python is used, and that reticulate does not install it's own Python + # see: https://rstudio.github.io/reticulate/reference/use_python.html + # see: https://github.com/rstudio/reticulate/issues/894 + txt += self.module_generator.set_environment('RETICULATE_PYTHON', os.path.join(pythonroot, 'bin', 'python')) + else: + self.log.info("Python not included as dependency, so RETICULATE_PYTHON not set") + + self.log.info("make_module_extra_ext_only added %s" % txt) + return txt From b006b56b34ad66cffd771192893eff46c8750584 Mon Sep 17 00:00:00 2001 From: Samuel Moors Date: Sun, 30 Jan 2022 18:07:35 +0100 Subject: [PATCH 2/3] remove unused import --- easybuild/easyblocks/r/reticulate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/easybuild/easyblocks/r/reticulate.py b/easybuild/easyblocks/r/reticulate.py index 1dbb14e415e..4925141d182 100644 --- a/easybuild/easyblocks/r/reticulate.py +++ b/easybuild/easyblocks/r/reticulate.py @@ -30,7 +30,6 @@ import os from easybuild.easyblocks.generic.rpackage import RPackage -from easybuild.tools.build_log import EasyBuildError from easybuild.tools.modules import get_software_root From 812855f8650425cc8e3d881351973e9d975b14e5 Mon Sep 17 00:00:00 2001 From: Samuel Moors Date: Sat, 5 Feb 2022 16:45:46 +0100 Subject: [PATCH 3/3] use run method --- easybuild/easyblocks/r/reticulate.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/easybuild/easyblocks/r/reticulate.py b/easybuild/easyblocks/r/reticulate.py index 4925141d182..2367b9cb60e 100644 --- a/easybuild/easyblocks/r/reticulate.py +++ b/easybuild/easyblocks/r/reticulate.py @@ -25,7 +25,7 @@ """ EasyBuild support for building and installing reticulate R package, implemented as an easyblock -@author: Samuel Moors (Vrije Universiteit Brussel +@author: Samuel Moors (Vrije Universiteit Brussel) """ import os @@ -36,10 +36,12 @@ class EB_reticulate(RPackage): """Support for installing the reticulate R package.""" - def make_module_extra_ext_only(self): + def run(self): """Add extra environment variables to modulefile""" - txt = super(EB_reticulate, self).make_module_extra_ext_only() + txt = super(EB_reticulate, self).run() + if not txt: + txt = "" pythonroot = get_software_root('Python') if pythonroot: @@ -50,5 +52,5 @@ def make_module_extra_ext_only(self): else: self.log.info("Python not included as dependency, so RETICULATE_PYTHON not set") - self.log.info("make_module_extra_ext_only added %s" % txt) + self.log.info("adding to modulefile: %s" % txt) return txt