Skip to content

fix: added check for FriCAS version #39796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all 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,5 +1,8 @@
SAGE_SPKG_CONFIGURE(
[fricas], [
dnl
dnl make sure that the minimal version is also set in src/sage/feature/fricas.py
dnl
AC_CACHE_CHECK([for FriCAS >= 1.3.8], [ac_cv_path_FRICAS], [
AC_PATH_PROGS_FEATURE_CHECK([FRICAS], [fricas], [
fricas_version=`echo ")quit" | $ac_path_FRICAS -nox -noclef | grep Version | tail -1 2>&1 \
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 @@
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 @@
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

Check warning on line 59 in src/sage/features/fricas.py

View check run for this annotation

Codecov / codecov/patch

src/sage/features/fricas.py#L53-L59

Added lines #L53 - L59 were not covered by tests

def is_functional(self):
r"""
Check whether ``fricas`` works on trivial input.
Expand All @@ -53,14 +73,24 @@
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,

Check warning on line 85 in src/sage/features/fricas.py

View check run for this annotation

Codecov / codecov/patch

src/sage/features/fricas.py#L83-L85

Added lines #L83 - L85 were not covered by tests
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")

Check warning on line 93 in src/sage/features/fricas.py

View check run for this annotation

Codecov / codecov/patch

src/sage/features/fricas.py#L88-L93

Added lines #L88 - L93 were not covered by tests


def all_features():
Expand Down
Loading