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

Conversation

devansh-srv
Copy link
Contributor

@devansh-srv devansh-srv commented Mar 26, 2025

This pull request includes several updates to the FriCAS class in the src/sage/features/fricas.py file. The changes introduce a minimum version requirement, add a method to retrieve the installed FriCAS version, and enhance the is_functional method to check the version.This is an attempt to fix the issue 39784

Enhancements to version handling and functionality checks:

  • src/sage/features/fricas.py: Added a MINIMUM_VERSION attribute to specify the minimum required version of FriCAS.
  • src/sage/features/fricas.py: Introduced a get_version method to retrieve the installed FriCAS version.
  • src/sage/features/fricas.py: Updated the is_functional method to call get_version and check if the installed version meets the minimum requirement. If the version is not retrievable or is too old, appropriate error messages are returned.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@devansh-srv
Copy link
Contributor Author

Hey @dimpase
I have checked that the url https://fricas.github.io/ refers to version 1.3.11
but this ticket concludes that FriCAS support was updated to 1.3.8
so I think 1.3.8 version check would be appropriate but I need to be sure
I am not on a Ubuntu machine (rather an arch machine)

@dimpase
Copy link
Member

dimpase commented Mar 26, 2025

indeed, anything earlier than 1.3.8 wasn't supported. Perhaps some tests, updated for newer FriCAS, might now fail, but that's OK

@tscrim
Copy link
Collaborator

tscrim commented Mar 28, 2025

cc-ing @mantepse just in case

Copy link

github-actions bot commented Mar 28, 2025

Documentation preview for this PR (built with commit 1e9cf1d; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dimpase
Copy link
Member

dimpase commented Mar 29, 2025

can we use a non-deprecated API here?

>>> from pkg_resources import parse_version
<stdin>:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

@dimpase
Copy link
Member

dimpase commented Mar 29, 2025

e.g. you can use https://packaging.pypa.io/en/stable/version.html

@devansh-srv
Copy link
Contributor Author

e.g. you can use https://packaging.pypa.io/en/stable/version.html

We can but is it causing any issue in the building process?

pkg_resources

@dimpase the package pkg_resources definitely needs to go as it is deprecated as shown by pytorch ticket 139170
I have made the necessary changes using the packaging.version package
I have also written and optional EXAMPLE doctest for the get_version() method
you may have a look on these latest changes

@devansh-srv
Copy link
Contributor Author

Please review the changes @dimpase

@dimpase
Copy link
Member

dimpase commented Apr 1, 2025

e.g. you can use https://packaging.pypa.io/en/stable/version.html

We can but is it causing any issue in the building process?

Deprecated features should not be used in newly written code, this is the only reason for my request

pkg_resources

@dimpase the package pkg_resources definitely needs to go as it is deprecated as shown by pytorch ticket 139170

There are more uses of it across Sage code,
which need fixing before we can remove it

I have made the necessary changes using the packaging.version package
I have also written and optional EXAMPLE doctest for the get_version() method
you may have a look on these latest changes

@devansh-srv
Copy link
Contributor Author

e.g. you can use https://packaging.pypa.io/en/stable/version.html

We can but is it causing any issue in the building process?

Deprecated features should not be used in newly written code, this is the only reason for my request

pkg_resources

@dimpase the package pkg_resources definitely needs to go as it is deprecated as shown by pytorch ticket 139170

There are more uses of it across Sage code, which need fixing before we can remove it

I have made the necessary changes using the packaging.version package
I have also written and optional EXAMPLE doctest for the get_version() method
you may have a look on these latest changes

In the latest changes I have remove pkg_resources and use the package that you have suggested
I think this should be fine

@devansh-srv
Copy link
Contributor Author

Hey @dimpase any specific instructions for me over this PR ?
Just needed to know if I need to change something

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your test for fricas version is too explicit. As we allow external fricas, it could be another version.

All you know is that's it's 1.3.something.

please replace 8 with dots, as done in such cases

@devansh-srv devansh-srv requested a review from dimpase April 4, 2025 05:14
Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the following comment

--- a/build/pkgs/fricas/spkg-configure.m4
+++ b/build/pkgs/fricas/spkg-configure.m4
@@ -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], [

Otherwise it's good to go.

@roed314 - please turn this to Positive review

@devansh-srv
Copy link
Contributor Author

Please add the following comment

--- a/build/pkgs/fricas/spkg-configure.m4
+++ b/build/pkgs/fricas/spkg-configure.m4
@@ -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], [

Otherwise it's good to go.

@roed314 - please turn this to Positive review

shall I do these changes now?

@dimpase
Copy link
Member

dimpase commented Apr 4, 2025

yes, of course.
At the moment we don't have a clear way to make sure there is only one source for the minimal version of an optional package like fricas,
so the purpose of this comment is to make sure that in the future these versions don't get out of sync.

vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 5, 2025
sagemathgh-39796: fix: added check for FriCAS version
    
This pull request includes several updates to the `FriCAS` class in the
`src/sage/features/fricas.py` file. The changes introduce a minimum
version requirement, add a method to retrieve the installed FriCAS
version, and enhance the `is_functional` method to check the
version.This is an attempt to fix the issue
[39784](sagemath#39784)

Enhancements to version handling and functionality checks:

* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR29-
R30): Added a `MINIMUM_VERSION` attribute to specify the minimum
required version of FriCAS.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR43-
R54): Introduced a `get_version` method to retrieve the installed FriCAS
version.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eL61-
R85): Updated the `is_functional` method to call `get_version` and check
if the installed version meets the minimum requirement. If the version
is not retrievable or is too old, appropriate error messages are
returned.
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39796
Reported by: Devansh Srivastava
Reviewer(s): Dima Pasechnik
@devansh-srv devansh-srv requested a review from dimpase April 6, 2025 16:52
@devansh-srv
Copy link
Contributor Author

@dimpase I have made the suggested changes in the file /build/pkgs/fricas/spkg-configure.m4
Have a look

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. @roed314 - please set the tag to positive review

@devansh-srv
Copy link
Contributor Author

devansh-srv commented Apr 9, 2025

Hi @dimpase
the builds fail because the ci scripts still try to build this using 10.6.x but the develop branch has been updated to 10.7.beta0 according to this commit
This may be a potential reason for failure
Besides I think dnl comments are also causing some issue as ./sage --br fails giving
./real_configure: line 28564: ${with_system_ fricas+y}: bad substitution
while this was working fine before adding these lines

@devansh-srv
Copy link
Contributor Author

@dimpase I have changed the position of dnl lines in the fricas/spkg-configure.m4
this is working fine on my machine.
Earlier it was throwing bad substitution error with the in the ./real_cofigure script

@dimpase
Copy link
Member

dimpase commented Apr 9, 2025

obviously you are expected to test your changes locally, in particular with such fragile tools like autoconf.

The change in the m4 file can be tested by running
./bootstrap (it should complete without errors)

@dimpase
Copy link
Member

dimpase commented Apr 9, 2025

once done, we'll need to ask @roed314 to make it positive review

@devansh-srv
Copy link
Contributor Author

once done, we'll need to ask @roed314 to make it positive review

I have tested the changes using ./bootstrap
it dumps the following at the end without any errors

configure.ac:64: installing 'config/compile'
configure.ac:64: installing 'config/config.guess'
configure.ac:64: installing 'config/config.sub'
configure.ac:50: installing 'config/install-sh'
configure.ac:50: installing 'config/missing'

I think this is good to go

@roed314
Copy link
Contributor

roed314 commented Apr 9, 2025

@dimpase Should I set this to positive review?

@dimpase
Copy link
Member

dimpase commented Apr 9, 2025

yes please.

@dimpase dimpase mentioned this pull request Apr 9, 2025
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 10, 2025
sagemathgh-39796: fix: added check for FriCAS version
    
This pull request includes several updates to the `FriCAS` class in the
`src/sage/features/fricas.py` file. The changes introduce a minimum
version requirement, add a method to retrieve the installed FriCAS
version, and enhance the `is_functional` method to check the
version.This is an attempt to fix the issue
[39784](sagemath#39784)

Enhancements to version handling and functionality checks:

* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR29-
R30): Added a `MINIMUM_VERSION` attribute to specify the minimum
required version of FriCAS.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR43-
R54): Introduced a `get_version` method to retrieve the installed FriCAS
version.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eL61-
R85): Updated the `is_functional` method to call `get_version` and check
if the installed version meets the minimum requirement. If the version
is not retrievable or is too old, appropriate error messages are
returned.
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39796
Reported by: Devansh Srivastava
Reviewer(s): Dima Pasechnik
@roed314
Copy link
Contributor

roed314 commented Apr 10, 2025

There's a test failure

sage -t --warn-long 5.0 --random-seed=117518158721644397165688698567845639636 src/sage/rings/real_mpfr.pyx
**********************************************************************
File "src/sage/rings/real_mpfr.pyx", line 3313, in sage.rings.real_mpfr.RealNumber._axiom_
Failed example:
    fricas(R(pi))                         # optional - fricas
Expected:
    3.1415926535_8979323846_26433833
Got:
    doctest:warning
      File "<doctest sage.rings.real_mpfr.RealNumber._axiom_[2]>", line 1, in <module>
        fricas(R(pi))                         # optional - fricas
      File "/sage/src/sage/interfaces/interface.py", line 306, in __call__
        result = self._coerce_from_special_method(x)
      File "/sage/src/sage/interfaces/interface.py", line 334, in _coerce_from_special_method
        return (x.__getattribute__(s))(self)
      File "/sage/src/sage/interfaces/interface.py", line 299, in __call__
        return cls(self, x, name=name)
      File "/sage/src/sage/interfaces/expect.py", line 1518, in __init__
        self._name = parent._create(value, name=name)
      File "/sage/src/sage/interfaces/interface.py", line 520, in _create
        self.set(name, value)
      File "/sage/src/sage/interfaces/fricas.py", line 680, in set
        output = self.eval(cmd, reformat=False)
      File "/sage/src/sage/interfaces/fricas.py", line 933, in eval
        output = Expect.eval(self, code, strip=strip,
      File "/sage/src/sage/interfaces/expect.py", line 1412, in eval
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 1412, in <genexpr>
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 988, in _eval_line
        self._start()
      File "/sage/src/sage/interfaces/fricas.py", line 347, in _start
        Expect._start(self)
      File "/sage/src/sage/interfaces/expect.py", line 512, in _start
        self._expect = SageSpawn(cmd,
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/pexpect/pty_spawn.py", line 205, in __init__
        self._spawn(command, args, preexec_fn, dimensions)
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/pexpect/pty_spawn.py", line 303, in _spawn
        self.ptyproc = self._spawnpty(self.args, env=self.env,
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/ptyprocess/ptyprocess.py", line 230, in spawn
        pid, fd = pty.fork()
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/pty.py", line 95, in fork
        pid, fd = os.forkpty()
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/warnings.py", line 112, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    DeprecationWarning: This process (pid=602670) is multi-threaded, use of forkpty() may lead to deadlocks in the child.
    doctest:warning
      File "<doctest sage.rings.real_mpfr.RealNumber._axiom_[2]>", line 1, in <module>
        fricas(R(pi))                         # optional - fricas
      File "/sage/src/sage/interfaces/interface.py", line 306, in __call__
        result = self._coerce_from_special_method(x)
      File "/sage/src/sage/interfaces/interface.py", line 334, in _coerce_from_special_method
        return (x.__getattribute__(s))(self)
      File "/sage/src/sage/interfaces/interface.py", line 299, in __call__
        return cls(self, x, name=name)
      File "/sage/src/sage/interfaces/expect.py", line 1518, in __init__
        self._name = parent._create(value, name=name)
      File "/sage/src/sage/interfaces/interface.py", line 520, in _create
        self.set(name, value)
      File "/sage/src/sage/interfaces/fricas.py", line 680, in set
        output = self.eval(cmd, reformat=False)
      File "/sage/src/sage/interfaces/fricas.py", line 933, in eval
        output = Expect.eval(self, code, strip=strip,
      File "/sage/src/sage/interfaces/expect.py", line 1412, in eval
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 1412, in <genexpr>
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 988, in _eval_line
        self._start()
      File "/sage/src/sage/interfaces/fricas.py", line 347, in _start
        Expect._start(self)
      File "/sage/src/sage/interfaces/expect.py", line 539, in _start
        quit.register_spawned_process(self._expect.pid, cmd)
      File "/sage/src/sage/interfaces/quit.py", line 67, in register_spawned_process
        start_cleaner()
      File "/sage/src/sage/interfaces/cleaner.py", line 30, in start_cleaner
        if not os.fork():
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/warnings.py", line 112, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    DeprecationWarning: This process (pid=602670) is multi-threaded, use of fork() may lead to deadlocks in the child.
    3.1415926535_8979323846_26433833
**********************************************************************
1 item had failures:
   1 of   4 in sage.rings.real_mpfr.RealNumber._axiom_
    [1054 tests, 1 failure, 4.55s wall]

@devansh-srv
Copy link
Contributor Author

devansh-srv commented Apr 10, 2025

There's a test failure

sage -t --warn-long 5.0 --random-seed=117518158721644397165688698567845639636 src/sage/rings/real_mpfr.pyx
**********************************************************************
File "src/sage/rings/real_mpfr.pyx", line 3313, in sage.rings.real_mpfr.RealNumber._axiom_
Failed example:
    fricas(R(pi))                         # optional - fricas
Expected:
    3.1415926535_8979323846_26433833
Got:
    doctest:warning
      File "<doctest sage.rings.real_mpfr.RealNumber._axiom_[2]>", line 1, in <module>
        fricas(R(pi))                         # optional - fricas
      File "/sage/src/sage/interfaces/interface.py", line 306, in __call__
        result = self._coerce_from_special_method(x)
      File "/sage/src/sage/interfaces/interface.py", line 334, in _coerce_from_special_method
        return (x.__getattribute__(s))(self)
      File "/sage/src/sage/interfaces/interface.py", line 299, in __call__
        return cls(self, x, name=name)
      File "/sage/src/sage/interfaces/expect.py", line 1518, in __init__
        self._name = parent._create(value, name=name)
      File "/sage/src/sage/interfaces/interface.py", line 520, in _create
        self.set(name, value)
      File "/sage/src/sage/interfaces/fricas.py", line 680, in set
        output = self.eval(cmd, reformat=False)
      File "/sage/src/sage/interfaces/fricas.py", line 933, in eval
        output = Expect.eval(self, code, strip=strip,
      File "/sage/src/sage/interfaces/expect.py", line 1412, in eval
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 1412, in <genexpr>
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 988, in _eval_line
        self._start()
      File "/sage/src/sage/interfaces/fricas.py", line 347, in _start
        Expect._start(self)
      File "/sage/src/sage/interfaces/expect.py", line 512, in _start
        self._expect = SageSpawn(cmd,
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/pexpect/pty_spawn.py", line 205, in __init__
        self._spawn(command, args, preexec_fn, dimensions)
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/pexpect/pty_spawn.py", line 303, in _spawn
        self.ptyproc = self._spawnpty(self.args, env=self.env,
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/ptyprocess/ptyprocess.py", line 230, in spawn
        pid, fd = pty.fork()
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/pty.py", line 95, in fork
        pid, fd = os.forkpty()
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/warnings.py", line 112, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    DeprecationWarning: This process (pid=602670) is multi-threaded, use of forkpty() may lead to deadlocks in the child.
    doctest:warning
      File "<doctest sage.rings.real_mpfr.RealNumber._axiom_[2]>", line 1, in <module>
        fricas(R(pi))                         # optional - fricas
      File "/sage/src/sage/interfaces/interface.py", line 306, in __call__
        result = self._coerce_from_special_method(x)
      File "/sage/src/sage/interfaces/interface.py", line 334, in _coerce_from_special_method
        return (x.__getattribute__(s))(self)
      File "/sage/src/sage/interfaces/interface.py", line 299, in __call__
        return cls(self, x, name=name)
      File "/sage/src/sage/interfaces/expect.py", line 1518, in __init__
        self._name = parent._create(value, name=name)
      File "/sage/src/sage/interfaces/interface.py", line 520, in _create
        self.set(name, value)
      File "/sage/src/sage/interfaces/fricas.py", line 680, in set
        output = self.eval(cmd, reformat=False)
      File "/sage/src/sage/interfaces/fricas.py", line 933, in eval
        output = Expect.eval(self, code, strip=strip,
      File "/sage/src/sage/interfaces/expect.py", line 1412, in eval
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 1412, in <genexpr>
        return '\n'.join(self._eval_line(L, allow_use_file=allow_use_file, **kwds)
      File "/sage/src/sage/interfaces/expect.py", line 988, in _eval_line
        self._start()
      File "/sage/src/sage/interfaces/fricas.py", line 347, in _start
        Expect._start(self)
      File "/sage/src/sage/interfaces/expect.py", line 539, in _start
        quit.register_spawned_process(self._expect.pid, cmd)
      File "/sage/src/sage/interfaces/quit.py", line 67, in register_spawned_process
        start_cleaner()
      File "/sage/src/sage/interfaces/cleaner.py", line 30, in start_cleaner
        if not os.fork():
      File "/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/warnings.py", line 112, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    DeprecationWarning: This process (pid=602670) is multi-threaded, use of fork() may lead to deadlocks in the child.
    3.1415926535_8979323846_26433833
**********************************************************************
1 item had failures:
   1 of   4 in sage.rings.real_mpfr.RealNumber._axiom_
    [1054 tests, 1 failure, 4.55s wall]

It somehow passed on my local machine

❯ ./sage -t --warn-long 5.0 --random-seed=117518158721644397165688698567845639636 src/sage/rings/real_mpfr.pyx
Running doctests with ID 2025-04-10-21-02-02-a029871f.
Git branch: FriCASVersionPatch
Git ref: 10.7.beta0-4-g1e9cf1ddcd2
Running with SAGE_LOCAL='/home/devansh/dev/gsoc/sage/local' and SAGE_VENV='/home/devansh/dev/gsoc/sage/local/var/lib/sage/venv-python3.12.5'
Using --optional=conda,fricas,pip,sage,sage_spkg,sagemath_giac
Features to be detected: 4ti2,SAGE_SRC,benzene,bliss,buckygen,conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_ellcurves,database_graphs,database_jones_numfield,database_knotinfo,dot2tex,dvipng,ecm,fpylll,fricas,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polenta,gap_package_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,giac,glucose,graphviz,imagemagick,info,ipython,jmol,jupymake,jupyter_sphinx,kenzo,kissat,latte_int,lrcalc_python,lrslib,mathics,matroid_database,mcqd,meataxe,meson_editable,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pycosat,pycryptosat,pynormaliz,pyparsing,python_igraph,requests,rpy2,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.braiding,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.giac,sage.libs.homfly,sage.libs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,scipy,singular,sirocco,sloane_database,sphinx,symengine_py,sympy,tdlib,threejs,topcom
Doctesting 1 file.
sage -t --warn-long 5.0 --random-seed=117518158721644397165688698567845639636 src/sage/rings/real_mpfr.pyx
    [1054 tests, 2.38s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 8.3 seconds
    cpu time: 2.3 seconds
    cumulative wall time: 2.4 seconds
Features detected for doctesting: numpy,sage.libs.pari,sage.rings.number_field,sage.symbolic,sympy

I am so confused because the test passed but this does not work

sage: fricas(R(pi))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/dev/gsoc/sage/src/sage/interfaces/expect.py:1518, in ExpectElement.__init__(self, parent, value, is_name, name)
   1517 try:
-> 1518     self._name = parent._create(value, name=name)
   1519 # Convert ValueError and RuntimeError to TypeError for
   1520 # coercion to work properly.

File ~/dev/gsoc/sage/src/sage/interfaces/interface.py:520, in Interface._create(self, value, name)
    519 name = self._next_var_name() if name is None else name
--> 520 self.set(name, value)
    521 return name

File ~/dev/gsoc/sage/src/sage/interfaces/fricas.py:681, in FriCAS.set(self, var, value)
    680 output = self.eval(cmd, reformat=False)
--> 681 self._check_errors(value, output)

File ~/dev/gsoc/sage/src/sage/interfaces/fricas.py:574, in FriCAS._check_errors(self, line, output)
    573         output = output.replace(old, new)
--> 574     raise RuntimeError("An error occurred when FriCAS evaluated '%s':\n%s" % (line, output))
    576 # or even an error

RuntimeError: An error occurred when FriCAS evaluated 'R Interpreter':
   There are no library operations named R 
      Use HyperDoc Browse or issue
                                   )what op R
      to learn if there is any operation containing " R " in its name.

 
   Cannot find a definition or applicable library operation named R with 
      argument type(s) 
                             Variable(Interpreter)
      
      Perhaps you should use "@" to indicate the required return type, or 
      "$" to specify which version of the function you need.



During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 fricas(R(pi)) 

File ~/dev/gsoc/sage/src/sage/misc/lazy_import.pyx:406, in sage.misc.lazy_import.LazyImport.__call__()
    404         True
    405     """
--> 406     return self.get_object()(*args, **kwds)
    407 
    408 def __repr__(self):

File ~/dev/gsoc/sage/src/sage/interfaces/interface.py:306, in Interface.__call__(self, x, name)
    299     return cls(self, x, name=name)
    300 try:
    301     # Special methods do not and should not have an option to
    302     # set the name directly, as the identifier assigned by the
    303     # interface should stay consistent. An identifier with a
    304     # user-assigned name might change its value, so we return a
    305     # new element.
--> 306     result = self._coerce_from_special_method(x)
    307     return result if name is None else result.name(new_name=name)
    308 except TypeError:

File ~/dev/gsoc/sage/src/sage/interfaces/interface.py:334, in Interface._coerce_from_special_method(self, x)
    332     s = '_gp_'
    333 try:
--> 334     return (x.__getattribute__(s))(self)
    335 except AttributeError:
    336     return self(x._interface_init_())

File ~/dev/gsoc/sage/src/sage/structure/sage_object.pyx:793, in sage.structure.sage_object.SageObject._fricas_()
    791         import sage.interfaces.fricas
    792         G = sage.interfaces.fricas.fricas
--> 793     return self._interface_(G)
    794 
    795 def _fricas_init_(self):

File ~/dev/gsoc/sage/src/sage/structure/sage_object.pyx:723, in sage.structure.sage_object.SageObject._interface_()
    721     except Exception:
    722         raise NotImplementedError("coercion of object %s to %s not implemented" % (repr(self), I))
--> 723 X = I(s)
    724 if c:
    725     try:

File ~/dev/gsoc/sage/src/sage/interfaces/interface.py:299, in Interface.__call__(self, x, name)
    296         pass
    298 if isinstance(x, str):
--> 299     return cls(self, x, name=name)
    300 try:
    301     # Special methods do not and should not have an option to
    302     # set the name directly, as the identifier assigned by the
    303     # interface should stay consistent. An identifier with a
    304     # user-assigned name might change its value, so we return a
    305     # new element.
    306     result = self._coerce_from_special_method(x)

File ~/dev/gsoc/sage/src/sage/interfaces/expect.py:1523, in ExpectElement.__init__(self, parent, value, is_name, name)
   1521 except (RuntimeError, ValueError) as x:
   1522     self._session_number = -1
-> 1523     raise TypeError(*x.args)
   1524 except BaseException:
   1525     self._session_number = -1

TypeError: An error occurred when FriCAS evaluated 'R Interpreter':
   There are no library operations named R 
      Use HyperDoc Browse or issue
                                   )what op R
      to learn if there is any operation containing " R " in its name.

 
   Cannot find a definition or applicable library operation named R with 
      argument type(s) 
                             Variable(Interpreter)
      
      Perhaps you should use "@" to indicate the required return type, or 
      "$" to specify which version of the function you need.

@dimpase
Copy link
Member

dimpase commented Apr 10, 2025

it's not really a failure, it's a deprecation warning popping up from (I guess) pexpect.
(sorry, it's about a different, earlier, message mentioned by David)

EDIT - it's actually from Python 3.12+, directly, see python/cpython#100229

It's an issue to look at, but orthogonal to this PR. @roed314

@dimpase
Copy link
Member

dimpase commented Apr 11, 2025

@devansh-srv - regaring fricas(R(pi)), that's due to R system interface being available in Sage.

vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 13, 2025
sagemathgh-39796: fix: added check for FriCAS version
    
This pull request includes several updates to the `FriCAS` class in the
`src/sage/features/fricas.py` file. The changes introduce a minimum
version requirement, add a method to retrieve the installed FriCAS
version, and enhance the `is_functional` method to check the
version.This is an attempt to fix the issue
[39784](sagemath#39784)

Enhancements to version handling and functionality checks:

* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR29-
R30): Added a `MINIMUM_VERSION` attribute to specify the minimum
required version of FriCAS.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eR43-
R54): Introduced a `get_version` method to retrieve the installed FriCAS
version.
* [`src/sage/features/fricas.py`](diffhunk://#diff-
a2c0d819d857ba2338e0d58e1a4875c88b600b174c8fb4371183ecc3f0e5b72eL61-
R85): Updated the `is_functional` method to call `get_version` and check
if the installed version meets the minimum requirement. If the version
is not retrievable or is too old, appropriate error messages are
returned.
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->



### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39796
Reported by: Devansh Srivastava
Reviewer(s): Dima Pasechnik
@vbraun vbraun merged commit 140e8be into sagemath:develop Apr 18, 2025
27 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants