Feat: make dockerfile to test my workflow

This commit is contained in:
Bertrand Benjamin 2022-05-09 09:09:38 +02:00
parent b1353bb6c7
commit fae2afa76c
8 changed files with 47 additions and 16 deletions

View File

@ -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
View 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

View File

@ -22,4 +22,4 @@ def curstomtex(command: str, options: str):
latexmk = curstomtex("latexmk", "-f")
pdflatex = curstomtex("pdflatex", "--inteactions=nonstopmode")
pdflatex = curstomtex("pdflatex", "--interaction=nonstopmode")

View File

@ -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])

View File

@ -0,0 +1,7 @@
from mapytex import Expression
from bopytex.jinja2_env.texenv import texenv
jinja2 = {
"environment": texenv,
}

View 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}

View File

@ -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))