Ask Your Question
2

TexShop sage.engine can't tell if running Sage is necessary

asked 2016-12-01 06:06:03 +0100

markus gravatar image

updated 2016-12-01 22:23:41 +0100

I have switched from sagetex.py version 2012/01/16 v2.3.3-69dcb0eb93de to version 2015/08/26 v3.0-92d9f7a. When I compile a tex file using sage.engine it can't determine whether sage needs to run or not. I've narrowed this down to the if statement in sage.engine

# do we need to run Sage?
if [ -f "$soutname" ]
then
    new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | md5)
    old_sum=$(egrep -o ^%[0-9a-f]{32}% "$soutname" | cut -b 2-33)
    if [ "$new_sum" != "$old_sum" ]
    then
        run_sage=yes
    fi
else
    # no .sout file, so run Sage
    run_sage=yes
fi

I think the first egrep call should also eliminate lines containing current_tex_line. I've tried

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '^( _st_.current_tex_line)' | md5)

but to no avail.

Any ideas would be much appreciated. Thanks.

Here is an example: the test.tex file

% !TEX TS-program = sage
\documentclass[12pt]{article}
\usepackage{sagetex}
\begin{document}
$2+3=\sage{2+3}$
\end{document}

produces among other things a sagetex.sout file that contains

% This file was *autogenerated* from test.sagetex.sage with
 % sagetex.py version 2015/08/26 v3.0-92d9f7a
\newlabel{@sageinline0}{{%
5}{}{}{}{}}
%b22d43e1240df548df8cf6749b32284b% md5sum of corresponding .sage file (minus "goboom", "current_tex_line", and pause/unpause lines)

The sage.engine if statement should compare the md5 value of sagetex.sage minus a few lines to the md5sum in sagetex.sout.

edit retag flag offensive close merge delete

Comments

I feel like this might have happened to me before, but certainly not consistently enough to have noticed it for sure. Can you give a minimal example of a file and a change in it that (reproducibly) doesn't trigger the recompile? That is what we'd really need to think about this properly.

kcrisman gravatar imagekcrisman ( 2016-12-01 14:54:39 +0100 )edit
1

Thanks for your response. I've added an example.

markus gravatar imagemarkus ( 2016-12-01 22:25:00 +0100 )edit

Glad you figured out your problem, but I still don't see what the line you would change would be that in the current SageTeX causes it not to recompile with Sage.

kcrisman gravatar imagekcrisman ( 2016-12-02 05:16:15 +0100 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2016-12-02 04:44:19 +0100

markus gravatar image

I've figured it out. Replacing the new_sum line sage.engine by

new_sum=$(egrep -v '^( _st_.goboom|print .SageT)' "$sagename" | egrep -v '(_st_.current_tex_line)' | md5)

does the trick.

edit flag offensive delete link more

Comments

If you think this is really a bug, I highly recommend emailing Richard Koch, the TeXShop author (http://pages.uoregon.edu/koch/texshop...) to report this. Apparently he is very responsive, or so the frequent updating would suggest.

kcrisman gravatar imagekcrisman ( 2016-12-02 05:22:11 +0100 )edit

As of TeXShop 3.77, this is in TeXShop! Thank you very much @markus!

kcrisman gravatar imagekcrisman ( 2017-06-07 16:27:06 +0100 )edit

Thank you very much! but didn't work. ;-) I needed also to change soutname as below!

MacOS 10.12.6 Beta SageMath version 7.6, Release Date: 2017-03-25 TexShop Version 3.77 (3.77)

qgfreire gravatar imageqgfreire ( 2017-07-10 16:36:27 +0100 )edit
0

answered 2017-04-20 17:02:50 +0100

Hi guys!

I think also line 8 in sage.engine can cause the same problem. In my experience if line 8 is soutname=${filename/%tex/.sout} md5 doesn’t recognise created file.

So I put soutname=${filename/%tex/sagetex.sout} and it can tell if running Sage is necessary.

What's your experience?

edit flag offensive delete link more

Comments

Again, you should bring these issues to the attention of the TeXShop developer, I don't think these files are in SageTeX itself - I think?

kcrisman gravatar imagekcrisman ( 2017-04-21 13:46:40 +0100 )edit

Thank you very much! It WORKED :-)

MacOS 10.12.6 Beta SageMath version 7.6, Release Date: 2017-03-25 TexShop Version 3.77 (3.77)

qgfreire gravatar imageqgfreire ( 2017-07-10 16:37:34 +0100 )edit

@qgfreire - Great! I also emailed the TeXShop developer about this one so I think it should be fixed eventually in TeXShop too.

kcrisman gravatar imagekcrisman ( 2017-07-10 16:46:43 +0100 )edit

I've confirmed this fix will be in TeXShop Version 3.80, which will probably be released soon this week.

kcrisman gravatar imagekcrisman ( 2017-07-10 20:13:47 +0100 )edit

when updated to 2023 sage.engine can't tell if running Sage is necessary because pattern not found in .sout.

I changed old_sum line to

   old_sum=$(egrep -o '^%[0-9a-f]{32}%' "$soutname" | cut -b 2-33)

putting the search pattern in between quotation marks or single quotes, both work.

Now is working.

qgfreire gravatar imageqgfreire ( 2023-07-01 13:53:50 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-12-01 06:06:03 +0100

Seen: 378 times

Last updated: Dec 02 '16