diff options
author | Matthew Sotoudeh <masotoudeh@ucdavis.edu> | 2020-09-13 16:13:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-13 16:13:59 -0700 |
commit | 696252c38a939599cc2f0ea8a05b135120e725d3 (patch) | |
tree | 8fcc686e71043195044eab3901d16c34d5b7681e /run_latex.py | |
parent | 20bf723dffea5aba9eee5101a1bcd9b8c9b2b90b (diff) |
Fixes to the arXiv-cleaning rules (#4)
Resolves Issue #3, now the arxiv-latex-cleaner rules should work correctly.
Diffstat (limited to 'run_latex.py')
-rw-r--r-- | run_latex.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/run_latex.py b/run_latex.py index 2d7d618..9f4b75e 100644 --- a/run_latex.py +++ b/run_latex.py @@ -1,5 +1,20 @@ #!/usr/bin/env python +"""Build a LaTeX project. + +Two invocations are supported: + +1) run_latex.py [texlive] [latexrun] [jobname] [mainfile].tex [outfile].pdf [sources...] +2) run_latex.py [texlive] [latexrun] [jobname] [mainfile].tex -- [sources...] -- [command...] + +The first will build [outfile].pdf from [mainfile].tex and the [sources...]. +This is used to build the PDF file for the [name]_getpdf rules. + +The second will build the paper, place [jobname].bbl in the current directory, +then call [command...]. This is used to build the bbl file for the +[name]_getarxivable rules. +""" + import glob import os import shutil @@ -8,6 +23,9 @@ import sys texlive, latexrun, job_name, main_file, output_file = sys.argv[1:6] sources = sys.argv[6:] +if output_file == "--": + run_after = sources[sources.index("--"):][1:] + sources = sources[:sources.index("--")] env = dict(os.environ) # Generated files (eg. outputs of pdfcrop) are placed under bazel-out/*/bin. @@ -40,4 +58,13 @@ return_code = subprocess.call( if return_code != 0: sys.exit(return_code) -os.rename(job_name + ".pdf", output_file) + +if output_file != "--": + os.rename(job_name + ".pdf", output_file) +else: + # Run the run_after script. + os.rename("latex.out/" + job_name + ".bbl", job_name + ".bbl") + return_code = subprocess.call( + args=run_after, + env=env, + ) |