Skip to content

Commit 45dbb00

Browse files
committed
feat(mathematica.py): Improve easyblock to support license server configuration and version-specific executable names
1 parent 3015d33 commit 45dbb00

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

easybuild/easyblocks/m/mathematica.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ def __init__(self, *args, **kwargs):
5959
def configure_step(self):
6060
"""No configuration for Mathematica."""
6161
# ensure a license server is specified
62-
if self.cfg['license_server'] is None:
63-
raise EasyBuildError("No license server specified.")
62+
# check environment variable if not set in easyconfig
63+
if self.cfg["license_server"] is None:
64+
self.cfg["license_server"] = os.getenv("EB_MATHEMATICA_LICENSE_SERVER")
65+
66+
if self.cfg["license_server"] is None:
67+
raise EasyBuildError("No license server specified via 'license_server' easyconfig parameter or "
68+
"$EB_MATHEMATICA_LICENSE_SERVER environment variable.")
6469

6570
def build_step(self):
6671
"""No build step for Mathematica."""
@@ -82,7 +87,12 @@ def install_step(self):
8287
install_script = matches[0]
8388
cmd = self.cfg['preinstallopts'] + './' + install_script
8489
shortver = '.'.join(self.version.split('.')[:2])
85-
qa_install_path = os.path.join('/usr', 'local', 'Wolfram', self.name, shortver)
90+
# Starting at V14, the product is called "Wolfram" instead of "Mathematica"
91+
if LooseVersion(self.version) >= LooseVersion("14"):
92+
product_name = "Wolfram"
93+
else:
94+
product_name = self.name
95+
qa_install_path = os.path.join('/usr', 'local', 'Wolfram', product_name, shortver)
8696
qa = [
8797
(r"Enter the installation directory, or press ENTER to select[\s\n]*%s:[\s\n]*>" % qa_install_path,
8898
self.installdir),
@@ -92,6 +102,13 @@ def install_step(self):
92102
]
93103
no_qa = [
94104
r"Now installing.*\n\n.*\[.*\].*",
105+
r"NOTE: Because you are not logged in with root privileges.*",
106+
r".*rpm -Uvh.*wolframscript.*",
107+
r".*Extracting installer.*",
108+
r".*\|\d+%",
109+
r".*Documentation.*Installer.*",
110+
r"You are not logged in with root privilege.*",
111+
r"The selected directory.*contains files.*",
95112
]
96113
run_shell_cmd(cmd, qa_patterns=qa, qa_wait_patterns=no_qa, qa_timeout=200)
97114
else:
@@ -138,14 +155,25 @@ def post_processing_step(self):
138155
def sanity_check_step(self):
139156
"""Custom sanity check for Mathematica."""
140157
custom_paths = {
141-
'files': ['bin/mathematica'],
158+
'files': ['bin/math'],
142159
'dirs': ['AddOns', 'Configuration', 'Documentation', 'Executables', 'SystemFiles'],
143160
}
161+
# Starting at V14, the main executable is called 'wolfram' instead of 'mathematica'
162+
if LooseVersion(self.version) >= LooseVersion("14"):
163+
custom_paths['files'].append('bin/wolfram')
164+
else:
165+
custom_paths['files'].append('bin/mathematica')
166+
144167
if LooseVersion(self.version) >= LooseVersion("11.3.0"):
145168
custom_paths['files'].append('Executables/wolframscript')
146169
elif LooseVersion(self.version) >= LooseVersion("11.0.0"):
147170
custom_paths['files'].append('bin/wolframscript')
148171

149-
custom_commands = ['mathematica --version']
172+
# Use appropriate executable for version check
173+
if LooseVersion(self.version) >= LooseVersion("14"):
174+
version_cmd = 'wolfram --version'
175+
else:
176+
version_cmd = 'mathematica --version'
177+
custom_commands = [version_cmd]
150178

151179
super().sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)

0 commit comments

Comments
 (0)