From 9e7edac26c9a31c2572d6d6b02395ea42102cdad Mon Sep 17 00:00:00 2001 From: casparl Date: Tue, 6 Jun 2023 15:50:12 +0200 Subject: [PATCH 1/4] Fixes https://github.com/easybuilders/easybuild-easyconfigs/issues/17593 --- easybuild/easyblocks/s/sympy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 easybuild/easyblocks/s/sympy.py diff --git a/easybuild/easyblocks/s/sympy.py b/easybuild/easyblocks/s/sympy.py new file mode 100644 index 0000000000..2d71a2f1c8 --- /dev/null +++ b/easybuild/easyblocks/s/sympy.py @@ -0,0 +1,19 @@ +# Author: Caspar van Leeuwen (SURF) + +import os +import tempfile + +from easybuild.easyblocks.generic.pythonpackage import PythonPackage + +class EB_sympy(PythonPackage): + """Build sympy""" + + def test_step(self): + original_tmpdir = tempfile.gettempdir() + print("Old TMPDIR: %s" % original_tmpdir) + tempfile.tempdir = os.path.realpath(tempfile.gettempdir()) + self.log.debug("Changing TMPDIR for test step to avoid easybuild-easyconfigs issue #17593.") + self.log.debug("Old TMPDIR %s. New TMPDIR %s.", original_tmpdir, tempfile.gettempdir()) + super(EB_sympy, self).test_step(self) + tempfile.tempdir = original_tmpdir + self.log.debug("Restored TMPDIR to %s", tempfile.gettempdir()) From 7750d7eb5361af2c11e259668e52529caf40126e Mon Sep 17 00:00:00 2001 From: casparl Date: Tue, 6 Jun 2023 15:52:09 +0200 Subject: [PATCH 2/4] Make the hound happy --- easybuild/easyblocks/s/sympy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/s/sympy.py b/easybuild/easyblocks/s/sympy.py index 2d71a2f1c8..3a0919e003 100644 --- a/easybuild/easyblocks/s/sympy.py +++ b/easybuild/easyblocks/s/sympy.py @@ -5,10 +5,11 @@ from easybuild.easyblocks.generic.pythonpackage import PythonPackage + class EB_sympy(PythonPackage): """Build sympy""" - def test_step(self): + def test_step(self): original_tmpdir = tempfile.gettempdir() print("Old TMPDIR: %s" % original_tmpdir) tempfile.tempdir = os.path.realpath(tempfile.gettempdir()) From 39cf722cfadbe3ceb6af17e3bb5474251e4962ca Mon Sep 17 00:00:00 2001 From: Simon Branford <4967+branfosj@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:03:44 +0100 Subject: [PATCH 3/4] Apply suggestions from code review --- easybuild/easyblocks/s/sympy.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/easybuild/easyblocks/s/sympy.py b/easybuild/easyblocks/s/sympy.py index 3a0919e003..f4d8f665af 100644 --- a/easybuild/easyblocks/s/sympy.py +++ b/easybuild/easyblocks/s/sympy.py @@ -1,4 +1,32 @@ -# Author: Caspar van Leeuwen (SURF) +## +# Copyright 2009-2023 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 sympy, implemented as an easyblock + +@author: Caspar van Leeuwen (SURF) +""" import os import tempfile @@ -10,8 +38,8 @@ class EB_sympy(PythonPackage): """Build sympy""" def test_step(self): + """Test step for sympy""" original_tmpdir = tempfile.gettempdir() - print("Old TMPDIR: %s" % original_tmpdir) tempfile.tempdir = os.path.realpath(tempfile.gettempdir()) self.log.debug("Changing TMPDIR for test step to avoid easybuild-easyconfigs issue #17593.") self.log.debug("Old TMPDIR %s. New TMPDIR %s.", original_tmpdir, tempfile.gettempdir()) From 6dab14ba84d0bcc19f8548ba3ac4704d138bead1 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Fri, 4 Aug 2023 13:46:27 +0200 Subject: [PATCH 4/4] enhance sympy easyblock by auto-enabling 'use_pip' & co, defining 'runtest' command, implementing custom sanity check --- easybuild/easyblocks/s/sympy.py | 45 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/easybuild/easyblocks/s/sympy.py b/easybuild/easyblocks/s/sympy.py index f4d8f665af..15e5186231 100644 --- a/easybuild/easyblocks/s/sympy.py +++ b/easybuild/easyblocks/s/sympy.py @@ -26,23 +26,56 @@ EasyBuild support for sympy, implemented as an easyblock @author: Caspar van Leeuwen (SURF) +@author: Kenneth Hoste (HPC-UGent) """ import os import tempfile -from easybuild.easyblocks.generic.pythonpackage import PythonPackage +from easybuild.easyblocks.generic.pythonpackage import PythonPackage, det_pylibdir class EB_sympy(PythonPackage): - """Build sympy""" + """Custom easyblock for installing the sympy Python package.""" + + @staticmethod + def extra_options(extra_vars=None): + """Customize default value for easyconfig parameters for sympy""" + extra_vars = PythonPackage.extra_options(extra_vars=extra_vars) + extra_vars['use_pip'][0] = True + extra_vars['sanity_pip_check'][0] = True + extra_vars['download_dep_fail'][0] = True + return extra_vars def test_step(self): - """Test step for sympy""" + """Custom test step for sympy""" + + self.cfg['runtest'] = "python setup.py test" + + # we need to make sure that the temporary directory being used is not a symlinked path; + # see https://github.com/easybuilders/easybuild-easyconfigs/issues/17593 original_tmpdir = tempfile.gettempdir() tempfile.tempdir = os.path.realpath(tempfile.gettempdir()) - self.log.debug("Changing TMPDIR for test step to avoid easybuild-easyconfigs issue #17593.") - self.log.debug("Old TMPDIR %s. New TMPDIR %s.", original_tmpdir, tempfile.gettempdir()) + msg = "Temporary directory set to resolved path %s (was %s), " % (original_tmpdir, tempfile.gettempdir()) + msg += "to avoid failing tests due to the temporary directory being a symlinked path..." + self.log.info(msg) + super(EB_sympy, self).test_step(self) + + # restore original temporary directory tempfile.tempdir = original_tmpdir - self.log.debug("Restored TMPDIR to %s", tempfile.gettempdir()) + self.log.debug("Temporary directory restored to %s", tempfile.gettempdir()) + + def sanity_check_step(self, *args, **kwargs): + """Custom sanity check for sympy.""" + + # can't use self.pylibdir here, need to determine path on the fly using currently active 'python' command; + # this is important for sympy installations for multiple Python version (via multi_deps) + custom_paths = { + 'files': [os.path.join('bin', 'isympy')], + 'dirs': [os.path.join(det_pylibdir(), 'sympy')], + } + + custom_commands = ["isympy --help"] + + return super(EB_sympy, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)