From 78f6ddc813506048eb5ac310c0b671248ce61057 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sun, 8 May 2022 09:15:13 +0200 Subject: [PATCH] Feat: dockerfile to test bopytex in new environment --- Dockerfile | 11 ++++++----- bopytex/worker/join_pdf.py | 21 ++++++++++++++++++--- setup.py | 24 +++++++++++------------- test/test_e2e.py | 2 +- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index dd0b1b8..c76e34c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ -FROM python:3.11-rc-alpine3.14 +FROM python:3.11-rc-slim -RUN apk add --no-cache --virtual python3-dev +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 @@ -8,8 +11,6 @@ RUN mkdir -p /src/bopytex COPY bopytex/ /src/bopytex COPY setup.py /src/ RUN pip install -e /src + COPY example /example - WORKDIR /example -CMD bopytex -n 2 tpl_example.tex - diff --git a/bopytex/worker/join_pdf.py b/bopytex/worker/join_pdf.py index 120df39..a89155c 100644 --- a/bopytex/worker/join_pdf.py +++ b/bopytex/worker/join_pdf.py @@ -2,17 +2,32 @@ import subprocess from bopytex.message import Message, SubprocessMessage + def pdfjam(args: dict, deps, output): joining_process = subprocess.Popen( - ["pdfjam"] + deps + ["-o", output], + ["pdfjam"] + deps + ["-o", output], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, ) - #return SubprocessMessage(joining_process) return Message( joining_process.wait(), list(joining_process.stdout), list(joining_process.stderr), - ) + ) + +def gs(args: dict, deps, output): + """ Not working. The command works in terminal but not here """ + joining_process = subprocess.Popen( + ["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"] + + deps, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + ) + return Message( + joining_process.wait(), + list(joining_process.stdout), + list(joining_process.stderr), + ) diff --git a/setup.py b/setup.py index 0de5bf0..4e1e194 100644 --- a/setup.py +++ b/setup.py @@ -4,20 +4,18 @@ from setuptools import setup setup( - name='Bopytex', - version='0.2', - description='Command line tool for compiling latex with python command embedded', - author='Benjamin Bertrand', - author_email='programming@opytex.org', - packages=['bopytex'], + name="Bopytex", + version="0.9", + description="Command line tool for compiling latex with python command embedded", + author="Benjamin Bertrand", + author_email="benjamin.bertrand@opytex.org", + packages=["bopytex"], install_requires=[ - 'click', - 'jinja2', - ], - entry_points={ - "console_scripts": ['bopytex=bopytex.script:new'] - }, - ) + "click", + "jinja2", + ], + entry_points={"console_scripts": ["bopytex=bopytex.script:new"]}, +) # ----------------------------- # Reglages pour 'vim' diff --git a/test/test_e2e.py b/test/test_e2e.py index 53c703b..66ca212 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -60,7 +60,7 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path): } for message in main(**options): - pass + assert message.status == 0 assert Path("joined_source.pdf").exists()