I am trying to use pythontex for SAGE computations inside a .tex document. I am aware that there exists a sagetex engine which allows for exactly my use case, but pythontex's concept of sessions is specially useful for me (some computations are very long, but don't change often, so splitting into sessions makes sense for me).
So far, it is easy to convince pythontex to use SAGE's python by running pythontex in this way:
pythontex --interpreter "python:sage -python" mainfile.tex
Question: SAGE offers a preparse(string) function to allow for extended syntax, e.g. the following is not legit python, but it is working SAGE:
R.<x,y>=QQ[]
How could I tell pythontex that I want to preparse inputs?
MWE:
\documentclass{article}
\usepackage[pyfuture=none]{pythontex}
% Run with: pythontex --interpreter "python:sage -python" main
\begin{pythontexcustomcode}{py}
# This works, I am using SAGE's python.
from sage.all import *
x,y,z,s,t,u,v=var("x,y,z,s,t,u,v")
\end{pythontexcustomcode}
\begin{document}
\begin{pycode}
# I want to apply preparse() to every pycode:
s=preparse('R.<x,y> = QQ[]\na=1')
print "\\begin{verbatim}\n%s\\end{verbatim}" % s
\end{pycode}
\end{document}
pythontexinternals. However, adding SAGE support topythontexshould be simple; probably only a few lines of code are needed. I've actually been waiting for someone to request SAGE support. I will see about adding SAGE support in the next day or so. – G. Poore Mar 13 '15 at 15:57