sagemath / sage-windows

Build tools for the Sagemath Windows installer
350 stars 47 forks source link

Suggestion : a Windows command-line executable #35

Open EmmanuelCharpentier opened 5 years ago

EmmanuelCharpentier commented 5 years ago

The practical usefulness of Sage is greatly enhanced by various third-party interfaces:

All of those interfaces need something that can be called from a shell ; at least one of them (sage-shell-mode) needs a Windows executable, and won't accept a shell script as a substitute (see this issue, currently unfixable). Using them entails installing the cygwin version of the relevant software. This can go a bit far, especially when you consider texlive; you end up installing a whole subsystem, which has to be maintained, and mostly duplicates functionality accessible from Windows...

Therefore, a "simple" sage.exe (which could be a simple redirector for stdin, stdout, stderr to a cygwin console, running minimized) might be useful in these circumstances, by allowing the Windows versions of the relevant software to use Sage.

embray commented 4 years ago

I agree this would be useful. Currently it does exist but in a non-obvious form, and consists of either running Sage's bash directly, or running Sage's Python directly (and in the latter case I think you still need to set some environment variables for that to work properly, but let me check that that hasn't been fixed...).

For example, from a Windows cmd prompt:

C:\> "C:\Users\<Username>\AppData\Local\SageMath 8.9\runtime\\bin\bash.exe" --norc --login "/opt/sagemath-8.9/local/bin/sage" -c "print(version())"
SageMath version 8.9, Release Date: 2019-09-29

By no means do I claim that it's obvious; I'm just saying that it is possible and the issue you linked to is likely fixable. Of course, patches are always welcome.

EmmanuelCharpentier commented 4 years ago

In fact, a binary executable may also be of use on Linux (possibly on Macs ?): One use case is the use of the reticulate package in R, companion to knitr, which allows the creation of LaTeX or Markdown text with R and Python chunks which can be evaluated (with cache if necessary) and the results (text or graphics) returned in the resultant text.

I tried, to no avail, to use $SAGE_ROOT/sage as the Python interpreter. This fails (probably because the IPython session doesn't get the right parameters). A pity...

This alternative to Sagetex, org-mode or PythonTeX/Codebraid could open Sage use to the (numerous) users of knitr.

Do you think that a discussion on sage-devel would be relevant ?

embray commented 4 years ago

In fact, a binary executable may also be of use on Linux (possibly on Macs ?)

I don't see what problem you think this will solve. It's already possible to use Sage's Python interpreter for other uses. The main issue with Sage is just setting the correct environment variables, especially $SAGE_ROOT. Having a binary executable or a shell script makes no difference here; there's nothing magic about binaries in this regard. It would only maybe be useful in Windows since Windows doesn't know how to execute a UNIX-style shell script (but the same could be achieved by a Windows batch script).

This fails (probably because the IPython session doesn't get the right parameters)

I'm not sure what you mean by this, but I don't think so. You mainly just need to set some environment variables.

See this on how to configure PyCharm to use Sage's Python as a Python interpreter.

It's effectively the same solution for any case where you want to use Sage's Python from a third-party application. It's not complicated or "unfixable" but it's not "obvious" either.