pythontex icon indicating copy to clipboard operation
pythontex copied to clipboard

Have a session which is always run when PythonTeX is run.

Open Cadair opened this issue 9 years ago • 2 comments

It would be neat if it were possible to have a specific code block that was always executed, this would be useful for when remote data changes or similar.

Maybe it would be good if you could specify a list of sessions at the start of the document that will always be executed, and maybe also include a cli flag, like for --rerun.

Cadair avatar Feb 05 '15 10:02 Cadair

I've been planning per-session options for some time, just haven't managed to finish the implementation. I'm just getting back to PythonTeX development after spending the last couple months putting out a new version of the minted syntax highlighting package, and will see what I can do over the next couple months.

In the meantime, you should be able to get the same effect through a relatively simple workaround/hack. Within the session that needs to run every time, you could use pytex.add_dependencies(<tex_log_file>). The .log file for the document gets a new modification time whenever you compile, so this session should always run. If you are using hashdependencies this wouldn't work if the contents of the .log remained constant. In that case, you might think about using the .aux file instead, and having TeX always write the current date and time to the .aux file so that its hash would always change. The datetime package could be useful for that.

gpoore avatar Feb 05 '15 14:02 gpoore

Cool, thanks for the workaround.

Cadair avatar Feb 05 '15 14:02 Cadair