Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/pkgs/fricas/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
SAGE_SPKG_CONFIGURE(
dnl
dnl make sure that the minimal version is also set in src/sage/feature/fricas.py
dnl
[fricas], [
AC_CACHE_CHECK([for FriCAS >= 1.3.8], [ac_cv_path_FRICAS], [
AC_PATH_PROGS_FEATURE_CHECK([FRICAS], [fricas], [
Expand Down
36 changes: 33 additions & 3 deletions src/sage/features/fricas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import subprocess
from . import Executable, FeatureTestResult
from packaging.version import Version


class FriCAS(Executable):
Expand All @@ -26,6 +27,8 @@ class FriCAS(Executable):
sage: FriCAS().is_present() # optional - fricas
FeatureTestResult('fricas', True)
"""
MINIMUM_VERSION = "1.3.8"

def __init__(self):
r"""
TESTS::
Expand All @@ -38,6 +41,23 @@ def __init__(self):
executable='fricas',
url='https://fricas.github.io')

def get_version(self):
r"""
Retrieve the installed FriCAS version

EXAMPLES::
sage: from sage.features.fricas import FriCAS
sage: FriCAS().get_version() # optional - fricas
'1.3...'
"""
try:
output = subprocess.check_output(['fricas', '--version'], stderr=subprocess.STDOUT)
version_line = output.decode('utf-8').strip()
version = version_line.split()[1]
return version
except subprocess.CalledProcessError:
return None

def is_functional(self):
r"""
Check whether ``fricas`` works on trivial input.
Expand All @@ -53,14 +73,24 @@ def is_functional(self):
lines = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
except subprocess.CalledProcessError as e:
return FeatureTestResult(self, False,
reason="Call `{command}` failed with exit code {e.returncode}".format(command=" ".join(command), e=e))
reason="Call `{command}` failed with exit code {e.returncode}".format(command=" ".join(command), e=e))

expected = b"FriCAS"
if lines.find(expected) == -1:
return FeatureTestResult(self, False,
reason="Call `{command}` did not produce output which contains `{expected}`".format(command=" ".join(command), expected=expected))
reason="Call `{command}` did not produce output which contains `{expected}`".format(command=" ".join(command),
expected=expected))
version = self.get_version()
if version is None:
return FeatureTestResult(self, False,
reason="Could not determine FriCAS version")

return FeatureTestResult(self, True)
try:
if Version(version) < Version(self.MINIMUM_VERSION):
return FeatureTestResult(self, False, reason=f"FriCAS version {version} is too old; minimum required is {self.MINIMUM_VERSION}")
return FeatureTestResult(self, True)
except ValueError:
return FeatureTestResult(self, False, reason="Invalid Version Format")


def all_features():
Expand Down
Loading