From 2e9e0836331098953e1e35b9aa6ddffa31043b26 Mon Sep 17 00:00:00 2001 From: Simon Branford Date: Sun, 7 Apr 2024 09:19:10 +0100 Subject: [PATCH 1/8] use `run_shell_cmd` in custom easyblock for Mathematica --- easybuild/easyblocks/m/mathematica.py | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index 4372c06f2d4..ef7d7cf5f57 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -1,5 +1,5 @@ ## -# Copyright 2013-2024 Ghent University +# Copyright 2013-2023 Ghent University # # This file is part of EasyBuild, # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), @@ -35,7 +35,7 @@ from easybuild.easyblocks.generic.binary import Binary from easybuild.framework.easyconfig import CUSTOM from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.run import run_cmd_qa +from easybuild.tools.run import run_shell_cmd class EB_Mathematica(Binary): @@ -76,16 +76,16 @@ def install_step(self): cmd = self.cfg['preinstallopts'] + './' + install_script shortver = '.'.join(self.version.split('.')[:2]) qa_install_path = os.path.join('/usr', 'local', 'Wolfram', self.name, shortver) - qa = { - r"Enter the installation directory, or press ENTER to select %s: >" % qa_install_path: self.installdir, - r"Create directory (y/n)? >": 'y', - r"Should the installer attempt to make this change (y/n)? >": 'n', - r"or press ENTER to select /usr/local/bin: >": os.path.join(self.installdir, "bin"), - } + qa = [ + (r"Enter the installation directory, or press ENTER to select %s: >" % qa_install_path, self.installdir), + (r"Create directory \(y/n\)\? >", 'y'), + (r"Should the installer attempt to make this change \(y/n\)\? >", 'n'), + (r"or press ENTER to select /usr/local/bin: >", os.path.join(self.installdir, "bin")), + ] no_qa = [ r"Now installing.*\n\n.*\[.*\].*", ] - run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True, maxhits=200) + run_shell_cmd(cmd, qa_patterns=qa, qa_wait_patterns=no_qa, qa_timeout=200) else: raise EasyBuildError("Failed to isolate install script using '%s': %s", install_script_glob, matches) @@ -113,15 +113,15 @@ def post_install_step(self): if self.cfg['activation_key']: # activation key is printed by using '$ActivationKey' in Mathematica, so no reason to keep it 'secret' self.log.info("Activating installation using provided activation key '%s'." % self.cfg['activation_key']) - qa = { - r"(enter return to skip Web Activation):": self.cfg['activation_key'], - r"In[1]:= ": 'Quit[]', - } - noqa = [ + qa = [ + (r"\(enter return to skip Web Activation\):", self.cfg['activation_key']), + (r"In\[1\]:= ", 'Quit[]'), + ] + no_qa = [ '^%s %s .*' % (self.name, self.version), '^Copyright.*', ] - run_cmd_qa(os.path.join(self.installdir, 'bin', 'math'), qa, no_qa=noqa) + run_shell_cmd(os.path.join(self.installdir, 'bin', 'math'), qa_patterns=qa, qa_wait_patterns=no_qa) else: self.log.info("No activation key provided, so skipping activation of the installation.") From 05b6492fb1a9703c6254b0b263520854db56ca47 Mon Sep 17 00:00:00 2001 From: Simon Branford <4967+branfosj@users.noreply.github.com> Date: Sun, 7 Apr 2024 09:19:50 +0100 Subject: [PATCH 2/8] f8 --- easybuild/easyblocks/m/mathematica.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index ef7d7cf5f57..a3b8d565d5f 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -77,7 +77,8 @@ def install_step(self): shortver = '.'.join(self.version.split('.')[:2]) qa_install_path = os.path.join('/usr', 'local', 'Wolfram', self.name, shortver) qa = [ - (r"Enter the installation directory, or press ENTER to select %s: >" % qa_install_path, self.installdir), + (r"Enter the installation directory, or press ENTER to select %s: >" % qa_install_path, + self.installdir), (r"Create directory \(y/n\)\? >", 'y'), (r"Should the installer attempt to make this change \(y/n\)\? >", 'n'), (r"or press ENTER to select /usr/local/bin: >", os.path.join(self.installdir, "bin")), From c7211a36a3b9bff1070813e59d6535286e14917c Mon Sep 17 00:00:00 2001 From: Simon Branford <4967+branfosj@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:49:53 +0100 Subject: [PATCH 3/8] revert accidental date change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikael Öhman --- easybuild/easyblocks/m/mathematica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index a3b8d565d5f..1ff4ad86876 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -1,5 +1,5 @@ ## -# Copyright 2013-2023 Ghent University +# Copyright 2013-2024 Ghent University # # This file is part of EasyBuild, # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), From 8d31e3de2be49fd9bd8db61f1c4ca8a1f3077977 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 11 Apr 2024 10:33:22 +0200 Subject: [PATCH 4/8] fix question pattern for specifying installation directory for Mathematica --- easybuild/easyblocks/m/mathematica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index 1ff4ad86876..aae427fd7d6 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -81,7 +81,7 @@ def install_step(self): self.installdir), (r"Create directory \(y/n\)\? >", 'y'), (r"Should the installer attempt to make this change \(y/n\)\? >", 'n'), - (r"or press ENTER to select /usr/local/bin: >", os.path.join(self.installdir, "bin")), + (r"or press ENTER to select[\s\n]*/usr/local/.*:[\s\n]*>", os.path.join(self.installdir, "bin")), ] no_qa = [ r"Now installing.*\n\n.*\[.*\].*", From 21377efbd3ef144cf7ad9431b4fa517dde006ce8 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 11 Apr 2024 10:34:40 +0200 Subject: [PATCH 5/8] fix indent --- easybuild/easyblocks/m/mathematica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index aae427fd7d6..64dab23237d 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -81,7 +81,7 @@ def install_step(self): self.installdir), (r"Create directory \(y/n\)\? >", 'y'), (r"Should the installer attempt to make this change \(y/n\)\? >", 'n'), - (r"or press ENTER to select[\s\n]*/usr/local/.*:[\s\n]*>", os.path.join(self.installdir, "bin")), + (r"or press ENTER to select[\s\n]*/usr/local/.*:[\s\n]*>", os.path.join(self.installdir, "bin")), ] no_qa = [ r"Now installing.*\n\n.*\[.*\].*", From 4b627a869e838a2a273aa7032bad42ce42c58b9f Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 11 Apr 2024 11:00:37 +0200 Subject: [PATCH 6/8] take into account line break in question patterns for Mathematica --- easybuild/easyblocks/m/mathematica.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index 64dab23237d..8d56b196cce 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -77,10 +77,10 @@ def install_step(self): shortver = '.'.join(self.version.split('.')[:2]) qa_install_path = os.path.join('/usr', 'local', 'Wolfram', self.name, shortver) qa = [ - (r"Enter the installation directory, or press ENTER to select %s: >" % qa_install_path, + (r"Enter the installation directory, or press ENTER to select %s:[\s\n]*>" % qa_install_path, self.installdir), - (r"Create directory \(y/n\)\? >", 'y'), - (r"Should the installer attempt to make this change \(y/n\)\? >", 'n'), + (r"Create directory \(y/n\)\?[\s\n]*>", 'y'), + (r"Should the installer attempt to make this change \(y/n\)\?[\s\n]*>", 'n'), (r"or press ENTER to select[\s\n]*/usr/local/.*:[\s\n]*>", os.path.join(self.installdir, "bin")), ] no_qa = [ From 4c72803c10669483765d18c7edefc1852b974ae2 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 11 Apr 2024 11:38:29 +0200 Subject: [PATCH 7/8] fix question pattern to replace /usr/local/bin in Mathematica easyblock --- easybuild/easyblocks/m/mathematica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index 8d56b196cce..3348aac5e9f 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -81,7 +81,7 @@ def install_step(self): self.installdir), (r"Create directory \(y/n\)\?[\s\n]*>", 'y'), (r"Should the installer attempt to make this change \(y/n\)\?[\s\n]*>", 'n'), - (r"or press ENTER to select[\s\n]*/usr/local/.*:[\s\n]*>", os.path.join(self.installdir, "bin")), + (r"or press ENTER to select[\s\n]*/usr/local/bin:[\s\n]*>", os.path.join(self.installdir, "bin")), ] no_qa = [ r"Now installing.*\n\n.*\[.*\].*", From 43f6ec76f9c9df34ca3480ed6f45651aa75eead0 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 11 Apr 2024 11:41:23 +0200 Subject: [PATCH 8/8] fix question pattern to specify installation prefix in Mathematica easyblock --- easybuild/easyblocks/m/mathematica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/m/mathematica.py b/easybuild/easyblocks/m/mathematica.py index 3348aac5e9f..cc6b68608ba 100644 --- a/easybuild/easyblocks/m/mathematica.py +++ b/easybuild/easyblocks/m/mathematica.py @@ -77,7 +77,7 @@ def install_step(self): shortver = '.'.join(self.version.split('.')[:2]) qa_install_path = os.path.join('/usr', 'local', 'Wolfram', self.name, shortver) qa = [ - (r"Enter the installation directory, or press ENTER to select %s:[\s\n]*>" % qa_install_path, + (r"Enter the installation directory, or press ENTER to select[\s\n]*%s:[\s\n]*>" % qa_install_path, self.installdir), (r"Create directory \(y/n\)\?[\s\n]*>", 'y'), (r"Should the installer attempt to make this change \(y/n\)\?[\s\n]*>", 'n'),