Feat: make dockerfile to test my workflow
This commit is contained in:
parent
b1353bb6c7
commit
fae2afa76c
@ -12,5 +12,5 @@ COPY bopytex/ /src/bopytex
|
||||
COPY setup.py /src/
|
||||
RUN pip install -e /src
|
||||
|
||||
COPY example /example
|
||||
COPY example/simple /example
|
||||
WORKDIR /example
|
||||
|
17
Dockerfile.mapytex
Normal file
17
Dockerfile.mapytex
Normal file
@ -0,0 +1,17 @@
|
||||
FROM python:3.11-rc-slim
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y texlive texlive-extra-utils
|
||||
|
||||
RUN apt-get install -y python3-dev
|
||||
COPY requirements.txt /tmp/
|
||||
RUN pip install -r /tmp/requirements.txt
|
||||
RUN pip install mapytex
|
||||
|
||||
RUN mkdir -p /src/bopytex
|
||||
COPY bopytex/ /src/bopytex
|
||||
COPY setup.py /src/
|
||||
RUN pip install -e /src
|
||||
|
||||
COPY example/mapytex /example
|
||||
WORKDIR /example
|
@ -22,4 +22,4 @@ def curstomtex(command: str, options: str):
|
||||
|
||||
|
||||
latexmk = curstomtex("latexmk", "-f")
|
||||
pdflatex = curstomtex("pdflatex", "--inteactions=nonstopmode")
|
||||
pdflatex = curstomtex("pdflatex", "--interaction=nonstopmode")
|
||||
|
@ -9,13 +9,10 @@ def generate(args, deps, output):
|
||||
|
||||
try:
|
||||
with open(output, "w") as out:
|
||||
out.write(tpl2tex(template, metas=args))
|
||||
fed = template.render(args)
|
||||
out.write(fed)
|
||||
|
||||
return Message(0, [f"GENERATE - {deps[0]} to {output}"], [])
|
||||
|
||||
except Exception as e:
|
||||
return Message(0, [], [e])
|
||||
|
||||
|
||||
def tpl2tex(template: Template, metas: dict = {}) -> str:
|
||||
return template.render(metas)
|
||||
return Message(1, [], [e])
|
||||
|
7
example/mapytex/bopytex_config.py
Normal file
7
example/mapytex/bopytex_config.py
Normal file
@ -0,0 +1,7 @@
|
||||
from mapytex import Expression
|
||||
|
||||
from bopytex.jinja2_env.texenv import texenv
|
||||
|
||||
jinja2 = {
|
||||
"environment": texenv,
|
||||
}
|
17
example/mapytex/tpl_example.tex
Normal file
17
example/mapytex/tpl_example.tex
Normal file
@ -0,0 +1,17 @@
|
||||
% vim:ft=tex:
|
||||
%
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\title{Bopytex with Mapytex example -- \Var{ number }}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
%- set e = Expression.random("{a} + {b}")
|
||||
\Var{e}
|
||||
|
||||
\Var{e.simplify()}
|
||||
|
||||
|
||||
\end{document}
|
@ -1,16 +1,9 @@
|
||||
import os
|
||||
import jinja2
|
||||
from bopytex.worker.generate import generate, tpl2tex
|
||||
from bopytex.worker.generate import generate
|
||||
import pytest
|
||||
|
||||
|
||||
def test_tpl2tex():
|
||||
tpl = "Plop {{a}}"
|
||||
jinja2_tpl = jinja2.Template(tpl)
|
||||
fed = tpl2tex(jinja2_tpl, metas={"a": 1})
|
||||
assert fed == "Plop 1"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jinja2_env(tmp_path):
|
||||
templateEnv = jinja2.Environment(loader=jinja2.FileSystemLoader(tmp_path))
|
||||
|
Loading…
Reference in New Issue
Block a user