Skip to content

Commit ffb15e1

Browse files
committed
fix: added check for FriCAS version
1 parent 276aa66 commit ffb15e1

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/sage/features/fricas.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class FriCAS(Executable):
2626
sage: FriCAS().is_present() # optional - fricas
2727
FeatureTestResult('fricas', True)
2828
"""
29+
MINIMUM_VERSION = "1.3.11"
30+
2931
def __init__(self):
3032
r"""
3133
TESTS::
@@ -38,6 +40,18 @@ def __init__(self):
3840
executable='fricas',
3941
url='https://fricas.github.io')
4042

43+
def get_version(self):
44+
r"""
45+
Retrieve the installed FriCAS version
46+
"""
47+
try:
48+
output = subprocess.check_output(['fricas', '--version'], stderr=subprocess.STDOUT)
49+
version_line = output.decode('utf-8').strip()
50+
version = version_line.split()[1]
51+
return version
52+
except subprocess.CalledProcessError:
53+
return None
54+
4155
def is_functional(self):
4256
r"""
4357
Check whether ``fricas`` works on trivial input.
@@ -53,13 +67,22 @@ def is_functional(self):
5367
lines = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
5468
except subprocess.CalledProcessError as e:
5569
return FeatureTestResult(self, False,
56-
reason="Call `{command}` failed with exit code {e.returncode}".format(command=" ".join(command), e=e))
70+
reason="Call `{command}` failed with exit code {e.returncode}".format(command=" ".join(command), e=e))
5771

5872
expected = b"FriCAS"
5973
if lines.find(expected) == -1:
6074
return FeatureTestResult(self, False,
61-
reason="Call `{command}` did not produce output which contains `{expected}`".format(command=" ".join(command), expected=expected))
75+
reason="Call `{command}` did not produce output which contains `{expected}`".format(command=" ".join(command),
76+
expected=expected))
77+
version = self.get_version()
78+
if version is None:
79+
return FeatureTestResult(self, False,
80+
reason="Could not determine FriCAS version")
6281

82+
from pkg_resources import parse_version
83+
if parse_version(version) < parse_version(self.MINIMUM_VERSION):
84+
return FeatureTestResult(self, False,
85+
reason=f"FriCAS version {version} is too old; minimum required is {self.MINIMUM_VERSION}")
6386
return FeatureTestResult(self, True)
6487

6588

0 commit comments

Comments
 (0)