Skip to content
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

Meson: add sage cli #39015

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

tobiasdiez
Copy link
Contributor

Meson currently doesn't install any of the scripts in src/bin. This is because

  • they mostly don't make sense for meson - especially doctests, sage packages interactions and various other developer tools shouldn't be installed for normal users
  • they rely on tricky environment variable manipulation
  • they use bash and thus do not work on Windows

Here, we reimplement a very small subset of the sage cli functionality in Python without any env hacks. At the moment only --version and the interactive sage shell are implemented.

What would be other command that make sense in the context of meson? We might also want to use the chance and reconsider the naming/layout of some of the commands.

📝 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

@antonio-rojas
Copy link
Contributor

I'd say sage -n to run the notebook directly and sage -c to run a single command should definitely be kept. I personally use sage -t a lot for running tests (I know it can be replaced with python -m sage.doctest, but the shortcut is quite handy)

@antonio-rojas
Copy link
Contributor

antonio-rojas commented Nov 22, 2024

The current version seems to work fine to launch sage, but fails at exit. Running exit gives

sage: ERROR:prompt_toolkit.buffer:Loading history failed
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/buffer.py", line 405, in load_history_done
    f.result()
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/buffer.py", line 393, in load_history
    async for item in self.history.load():
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/history.py", line 60, in load
    self._loaded_strings = list(self.load_history_strings())
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/IPython/terminal/interactiveshell.py", line 190, in load_history_strings
    for __, ___, cell in self.shell.history_manager.get_tail(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_tail'

Unhandled exception in event loop:
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/buffer.py", line 393, in load_history
    async for item in self.history.load():
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/history.py", line 60, in load
    self._loaded_strings = list(self.load_history_strings())
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/IPython/terminal/interactiveshell.py", line 190, in load_history_strings
    for __, ___, cell in self.shell.history_manager.get_tail(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception 'NoneType' object has no attribute 'get_tail'
Press ENTER to continue...

and trying with CTRL+D gives

sage:                                                                                                                                                     
/usr/lib/python3.12/site-packages/sage/misc/banner.py:66: DeprecationWarning: Use sage.version instead.
See https://github.com/sagemath/sage/issues/1 for details.
  a("\n│ %-66s │\n" % version())

and displays the banner again. Pressing CTRL+D once again finally exits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants