gpoore/pythontex — pull request #40 by rolk (2014-04-04 10:35:43+00:00)
Title: Log if the generated Python output file is missing

When the package expects Python output to be present, it attempts to input the .pytxmcr file. If this file is not found, nothing was done, expecting the user to know that pythontex.py should be run.

This patch prints a message to the log which enables scripts such as latexmk to deduce that a file is missing and run pythontex.py automatically to create it (and re-run latex on the original document afterwards).

Such a dependency can be setup if you add the following lines to your latexmkrc:

add_cus_dep('pytxcode','pytxmcr',0,'pythontex');
sub pythontex { return system("pythontex.py \"$_[0]\""); }

When latexmk sees that the .pytxmcr file is missing, it will make it from .pytxcode. When changes are detected for the .pytxcode, it will re-run pythontex.py to update the .pytxmcr file.

Currently, this requires you to specify

\setpythontexoutputdir{.}

so that the .pytxmcr file is expected to be in the same directory as the .pytxcode, as this is the only place latexmk will look for it.