Skip to content

Commit

Permalink
use latexmk
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor committed Apr 3, 2018
1 parent 4903307 commit f0fd692
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ RUN tlmgr install xcolor \
helvetic \
charter

# Install latexmk.
RUN tlmgr install latexmk

# Remove LuaTeX.
RUN tlmgr remove --force luatex

Expand All @@ -70,12 +73,19 @@ RUN rm -rf /var/task/texlive/2017/tlpkg/texlive.tlpdb* \
/var/task/texlive/2017/texmf-dist/source/latex/koma-script/doc \
/var/task/texlive/2017/texmf-dist/doc

RUN mkdir -p /var/task/texlive/2017/tlpkg/TeXLive/Digest/ && \
mkdir -p /var/task/texlive/2017/tlpkg/TeXLive/auto/Digest/MD5/ && \
cp /usr/lib64/perl5/vendor_perl/Digest/MD5.pm \
/var/task/texlive/2017/tlpkg/TeXLive/Digest/ && \
cp /usr/lib64/perl5/vendor_perl/auto/Digest/MD5/MD5.so \
/var/task/texlive/2017/tlpkg/TeXLive/auto/Digest/MD5

FROM lambci/lambda:build-python3.6

WORKDIR /var/task

ENV PATH=/var/task/texlive/2017/bin/x86_64-linux/:$PATH
ENV PERL5LIB=/var/task/texlive/2017/tlpkg/TeXLive/

COPY --from=0 /var/task/ /var/task/
COPY lambda_function.py /var/task
19 changes: 11 additions & 8 deletions lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ def lambda_handler(event, context):

os.environ['PATH'] += ":/var/task/texlive/2017/bin/x86_64-linux/"
os.environ['HOME'] = "/tmp/latex/"
os.environ['PERL5LIB'] = "/var/task/texlive/2017/tlpkg/TeXLive/"

os.chdir("/tmp/latex/")

# Run pdflatex...
for i in [1, 2]:
r = subprocess.run(["/var/task/texlive/2017/bin/x86_64-linux/pdflatex",
"-interaction=batchmode",
"-output-directory=/tmp/latex",
"document.tex"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
print(r.stdout.decode('utf_8'))
r = subprocess.run(["latexmk",
"-verbose",
"-interaction=batchmode",
"-pdf",
"-output-directory=/tmp/latex",
"document.tex"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
print(r.stdout.decode('utf_8'))

# Read "document.pdf"...
with open("document.pdf", "rb") as f:
Expand Down
7 changes: 5 additions & 2 deletions make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module MakeLatexLambda
using JSON
using AWSCore
using AWSS3
#using AWSLambda
using AWSLambda
using InfoZIP

function all()
Expand Down Expand Up @@ -62,10 +62,13 @@ test_zip = base64encode(create_zip("document.tex" =>

# Test latex in local docker image.
function localtest()
write("test_input.zip.base64", test_zip)
pycmd = """
import lambda_function
import json
out = lambda_function.lambda_handler({'input': '$test_zip'}, {})
import base64
out = lambda_function.lambda_handler(
{'input': open('/var/host/test_input.zip.base64').read()}, {})
with open('/var/host/test_output.json', 'w') as f:
f.write(json.dumps(out))
"""
Expand Down

0 comments on commit f0fd692

Please sign in to comment.