diff options
Diffstat (limited to 'Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc')
-rw-r--r-- | Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc | 80 |
1 files changed, 26 insertions, 54 deletions
diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc index 26d2a19a7aa..ba02de3ee78 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc @@ -1,67 +1,39 @@ -# Support for pythontex in v. 0.16 or higher. +# Support for pythontex in v. 0.16 or higher, with latexmk 4.62 or higher # # What these definitions provide/do: # 1. Variable specifying command string for invoking pythontex -# 2. Definition of commands for latex, pdflatex, etc to call a -# subroutine latex_python that implements the necessary -# functionality, as follows: -# a. The latex, pdflatex program, etc is run. -# b. It is determined whether a file $root.pytxcode was generated -# during the run. Here $root is the root name of the primary -# document file. The $root.pytxcode, if present, is created in -# the output directory (or more exactly, the aux directory, if -# different from the output directory. It is a symptom of the -# use of pythontex. -# c. If the file is present, a rule for running pythontex is set -# up, if it has not already been created. -# d. The source file for the rule is $root.pytxcode and the -# destination file is named $root.pytxmcr, which is always -# created in a subdirectory named pythontex-files-$root of the -# aux or output directory. The file $root.pytxmcr is always -# created when pythontex is run, and is read when a document -# using pythontex is compiled (by latex, or pdflatex, etc) -# e. If that rule is being created for the first time, a message is -# appended to the .log file of the latex run about the -# $root.pytxmcr filename (with the appropriate prefix -# directory). This ensures that at the next stage of the -# processing, when latexmk examines the run's .log file, it -# creates appropriate dependency information and links the -# pythontex rule into the network of dependencies. -# 3. Settings for the files generated by the pythontex package and the +# 2. Addition to %extra_rule_spec of template for pythontex rule. This +# tells latexmkrc to create the rule when it is initializing for +# processing a TeX file. +# 3. A subroutine mypythontex that the pythontex rule is defined to +# call. This runs pythontex and then sets dependency information. +# 4. Settings for the files generated by the pythontex package and the # pythontex program so that the files are deleted in a clean-up # operation. -$clean_ext .= " pythontex-files-%R/*"; +$clean_ext .= " pythontex-files-%R/* pythontex-files-%R"; push @generated_exts, 'pytxcode'; $pythontex = 'pythontex %O %S'; +$extra_rule_spec{'pythontex'} = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode", "%Ypythontex-files-%R/%R.pytxmcr", "%R", 1 ]; -foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) { - ${$cmd} = "internal latex_python %R %Y $cmd %O %S"; -} - -sub latex_python { - # Run *latex, then set pythontex rule if needed. - # Arguments: Root name, directory for aux files (with terminator), - # latex program to run, arguments for latex. - - my $root = shift; - my $dir_string = shift; - my $pytx_code = "$dir_string$root.pytxcode"; - my $result_dir = $dir_string."pythontex-files-$root"; - my $pytx_out_file = "$result_dir/$root.pytxmcr"; - my $pytx_rule_name = "pythontex $root"; - my $ret = system @_; - if ( test_gen_file( $pytx_code ) ) { - print "=== Pythontex being used\n"; - if (! rdb_rule_exists( $pytx_rule_name ) ) { - print "=== Creating rule '$pytx_rule_name'\n"; - rdb_create_rule( $pytx_rule_name, 'external', $pythontex, '', 1, - $pytx_code, $pytx_out_file, $root, 1 ); - system "echo No file \"$pytx_out_file\". >> \"$dir_string$root.log\""; - } +sub mypythontex { + my $result_dir = $aux_dir1."pythontex-files-$$Pbase"; + my $ret = Run_subst( $pythontex, 2 ); + rdb_add_generated( glob "$result_dir/*" ); + my $fh = new FileHandle $$Pdest, "r"; + if ($fh) { + while (<$fh>) { + if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) { + print "Found pythontex dependency '$1'\n"; + rdb_ensure_file( $rule, $aux_dir1.$1 ); + } + } + undef $fh; + } + else { + warn "mypythontex: I could not read '$$Pdest'\n", + " to check dependencies\n"; } return $ret; } - - |