Compare commits

...

12 Commits

Author SHA1 Message Date
Bertrand Benjamin 3c39a42562 Fix: correct README according to simple example
continuous-integration/drone/push Build is passing Details
2022-08-06 20:29:02 +02:00
Bertrand Benjamin a911b98520 Feat: produce joined_example.pdf for the two examples
continuous-integration/drone/push Build is passing Details
2022-08-06 18:04:46 +02:00
Bertrand Benjamin bf237d77e5 Feat: add make commands in README 2022-08-06 17:25:51 +02:00
Bertrand Benjamin a8d2fa2ed6 Feat: add dependencies in README 2022-08-06 17:18:09 +02:00
Bertrand Benjamin bde6c11a27 Fix: add latexmk
continuous-integration/drone/push Build is passing Details
2022-07-29 15:20:30 +02:00
Bertrand Benjamin 923cb16c66 Core: user 3.11 for drone pipeline
continuous-integration/drone/push Build encountered an error Details
2022-07-28 19:10:32 +02:00
Bertrand Benjamin 51d4d32849 Feat: add update package list first
continuous-integration/drone/push Build is failing Details
2022-07-28 15:08:15 +02:00
Bertrand Benjamin 251350f30e Feat: add install of textlive in pipelines
continuous-integration/drone/push Build is failing Details
2022-07-28 15:07:17 +02:00
Bertrand Benjamin 62253cb3ba Core: add pytest in dev-dependencies
continuous-integration/drone/push Build is failing Details
2022-07-28 15:02:27 +02:00
Bertrand Benjamin 5efc9a63ea Feat: add test and update publish for drone
continuous-integration/drone/push Build is failing Details
2022-07-28 14:58:44 +02:00
Bertrand Benjamin a0f93cc5b7 Core: add tox in dev-dependencies 2022-07-28 10:08:38 +02:00
Bertrand Benjamin 81b64c525c Core: add tox for testing 2022-07-28 10:07:21 +02:00
11 changed files with 311 additions and 21 deletions

View File

@ -1,13 +1,28 @@
---
kind: pipeline
name: default
steps:
- name: Tests
image: python:3.10
environment:
PyPI_TOKEN: pypi_token
commands:
- apt-get update
- apt-get install -y texlive texlive-extra-utils latexmk
- python -m pip install --upgrade pip
- python -m pip install poetry
- poetry install
- poetry run pytest
- name: Publish
image: plugins/pypi
settings:
username:
from_secret: pypi_username
password:
from_secret: pypi_password
image: python:3.10
environment:
PyPI_TOKEN: pypi_token
commands:
- python -m pip install --upgrade pip
- python -m pip install poetry
- poetry config pypi-token.pypi $PyPI_TOKEN
- poetry publish --build
when:
event: tag

View File

@ -2,10 +2,18 @@ docker-build-simple:
docker build -f Dockerfile.simple -t simple .
docker-simple: docker-build-simple
docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat 1_example.tex"
docker run simple sh -c "bopytex -q 2 tpl_example.tex && ls"
docker-build-usecase:
docker build -f Dockerfile.usecase -t usecase .
docker-usecase: docker-build-usecase
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex"
usecase-example: docker-build-usecase
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat joined_example.pdf" > example/usecase/joined_example.pdf
simple-example: docker-build-simple
docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat joined_example.pdf" > example/simple/joined_example.pdf
examples: usecase-example simple-example

View File

@ -6,6 +6,8 @@ Bopytex is a command line tool which embed python into latex. It uses jinja2 to
## Installing
Bopytex depends on `texlive` and `textlive-extra-utils` (for latexmk and pdfjoin)
Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/)
pip install -U bopytex
@ -29,19 +31,31 @@ We have two variables
\item n: \Var{n}
\end{itemize}
%# We can use blocks
\section{Variables}
\subsection{subject}
\begin{itemize}
%- for i in n
\item \Var{a}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}
```
To create a version a this document type this
The following command produces the [joined_example.pdf](./example/simple/joined_example.pdf) document
``` bash
$ bopytex tpl_simple.tex
@ -56,11 +70,11 @@ To produce formulas and values, I use an another tool I an developing: `mapytex
``` python
# bopytex_config.py
from mapytex import Expression
from random import random
random.seed(0) # Controlling the seed allows to make subject reproductible
direct_access = {
"Expression": Expression,
"random": random
}
```
@ -81,6 +95,27 @@ Every variables, objects or function inside this file will be available inside t
\Var{e.simplify()}
\section{Variables}
\subsection{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}
```
@ -95,8 +130,21 @@ Information about my students are stored in a csv file (here `students.csv`)
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"
```
Then I can produce a subject for each of my student
Then I can produce a [subject for each of my student](./example/usecase/joined_example.pdf)
``` bash
$ bopytex tpl_simple.tex -s students.csv -c bopytex_config.py
```
## Running examples
I build two examples base of the simple example and how I use it. They are playable through dockerfiles with make commands.
For the simple example
make docker-simple
For how I use it
make docker-usecase

Binary file not shown.

View File

@ -22,9 +22,23 @@ We have two variables
\section{Variables}
\subsection{subject}
\Var{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\Var{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}

View File

@ -1,3 +1,7 @@
import random
from mapytex import Expression
direct_access = {"Expression": Expression}
random.seed(0)
direct_access = {"Expression": Expression, "random": random.random}

Binary file not shown.

View File

@ -15,8 +15,22 @@
\section{Variables}
\subsection{subject}
\Var{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\Var{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}

176
poetry.lock generated
View File

@ -1,3 +1,25 @@
[[package]]
name = "atomicwrites"
version = "1.4.1"
description = "Atomic file writes."
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
version = "21.4.0"
description = "Classes Without Boilerplate"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[package.extras]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
[[package]]
name = "cfgv"
version = "3.3.1"
@ -56,6 +78,14 @@ python-versions = ">=3.7"
[package.extras]
license = ["ukkonen"]
[[package]]
name = "iniconfig"
version = "1.1.1"
description = "iniconfig: brain-dead simple config-ini parsing"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "jinja2"
version = "3.1.2"
@ -86,6 +116,17 @@ category = "dev"
optional = false
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
[[package]]
name = "packaging"
version = "21.3"
description = "Core utilities for Python packages"
category = "dev"
optional = false
python-versions = ">=3.6"
[package.dependencies]
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
[[package]]
name = "platformdirs"
version = "2.5.2"
@ -98,6 +139,18 @@ python-versions = ">=3.7"
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"]
test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"]
[[package]]
name = "pluggy"
version = "1.0.0"
description = "plugin and hook calling mechanisms for python"
category = "dev"
optional = false
python-versions = ">=3.6"
[package.extras]
testing = ["pytest-benchmark", "pytest"]
dev = ["tox", "pre-commit"]
[[package]]
name = "pre-commit"
version = "2.20.0"
@ -114,6 +167,46 @@ pyyaml = ">=5.1"
toml = "*"
virtualenv = ">=20.0.8"
[[package]]
name = "py"
version = "1.11.0"
description = "library with cross-python path, ini-parsing, io, code, log facilities"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pyparsing"
version = "3.0.9"
description = "pyparsing module - Classes and methods to define and execute parsing grammars"
category = "dev"
optional = false
python-versions = ">=3.6.8"
[package.extras]
diagrams = ["railroad-diagrams", "jinja2"]
[[package]]
name = "pytest"
version = "7.1.2"
description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
attrs = ">=19.2.0"
colorama = {version = "*", markers = "sys_platform == \"win32\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=0.12,<2.0"
py = ">=1.8.2"
tomli = ">=1.0.0"
[package.extras]
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
[[package]]
name = "pyyaml"
version = "6.0"
@ -122,6 +215,14 @@ category = "dev"
optional = false
python-versions = ">=3.6"
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "toml"
version = "0.10.2"
@ -130,6 +231,36 @@ category = "dev"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "tomli"
version = "2.0.1"
description = "A lil' TOML parser"
category = "dev"
optional = false
python-versions = ">=3.7"
[[package]]
name = "tox"
version = "3.25.1"
description = "tox is a generic virtualenv management and test command line tool"
category = "dev"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[package.dependencies]
colorama = {version = ">=0.4.1", markers = "platform_system == \"Windows\""}
filelock = ">=3.0.0"
packaging = ">=14"
pluggy = ">=0.12.0"
py = ">=1.4.17"
six = ">=1.14.0"
toml = ">=0.9.4"
virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7"
[package.extras]
docs = ["pygments-github-lexers (>=0.0.5)", "sphinx (>=2.0.0)", "sphinxcontrib-autoprogram (>=0.1.5)", "towncrier (>=18.5.0)"]
testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pytest (>=4.0.0)", "pytest-cov (>=2.5.1)", "pytest-mock (>=1.10.0)", "pytest-randomly (>=1.0.0)", "psutil (>=5.6.1)", "pathlib2 (>=2.3.3)"]
[[package]]
name = "virtualenv"
version = "20.16.2"
@ -150,9 +281,16 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)",
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "a5f3c648ba2e1f31104bdf2c1e9f76dcbe7e324bf8c8d720fa160fd070bcd38a"
content-hash = "2e8e9679154491f8e2d8611aa619ec3b2be4be7b48b6a654230459b076b51886"
[metadata.files]
atomicwrites = [
{file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
]
attrs = [
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
]
cfgv = [
{file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"},
{file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"},
@ -177,6 +315,10 @@ identify = [
{file = "identify-2.5.2-py2.py3-none-any.whl", hash = "sha256:feaa9db2dc0ce333b453ce171c0cf1247bbfde2c55fc6bb785022d411a1b78b5"},
{file = "identify-2.5.2.tar.gz", hash = "sha256:a3d4c096b384d50d5e6dc5bc8b9bc44f1f61cefebd750a7b3e9f939b53fb214d"},
]
iniconfig = [
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
]
jinja2 = [
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
@ -227,14 +369,34 @@ nodeenv = [
{file = "nodeenv-1.7.0-py2.py3-none-any.whl", hash = "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e"},
{file = "nodeenv-1.7.0.tar.gz", hash = "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"},
]
packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
]
platformdirs = [
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
{file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
]
pluggy = [
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
]
pre-commit = [
{file = "pre_commit-2.20.0-py2.py3-none-any.whl", hash = "sha256:51a5ba7c480ae8072ecdb6933df22d2f812dc897d5fe848778116129a681aac7"},
{file = "pre_commit-2.20.0.tar.gz", hash = "sha256:a978dac7bc9ec0bcee55c18a277d553b0f419d259dadb4b9418ff2d00eb43959"},
]
py = [
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
]
pyparsing = [
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
]
pytest = [
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pyyaml = [
{file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"},
{file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"},
@ -270,10 +432,22 @@ pyyaml = [
{file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"},
{file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"},
]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
]
tox = [
{file = "tox-3.25.1-py2.py3-none-any.whl", hash = "sha256:c38e15f4733683a9cc0129fba078633e07eb0961f550a010ada879e95fb32632"},
{file = "tox-3.25.1.tar.gz", hash = "sha256:c138327815f53bc6da4fe56baec5f25f00622ae69ef3fe4e1e385720e22486f9"},
]
virtualenv = [
{file = "virtualenv-20.16.2-py2.py3-none-any.whl", hash = "sha256:635b272a8e2f77cb051946f46c60a54ace3cb5e25568228bd6b57fc70eca9ff3"},
{file = "virtualenv-20.16.2.tar.gz", hash = "sha256:0ef5be6d07181946891f5abc8047fda8bc2f0b4b9bf222c64e6e8963baee76db"},

View File

@ -13,6 +13,8 @@ Jinja2 = "^3.1.2"
[tool.poetry.dev-dependencies]
pre-commit = "^2.20.0"
tox = "^3.25.1"
pytest = "^7.1.2"
[build-system]
requires = ["poetry-core>=1.0.0"]

11
tox.ini Normal file
View File

@ -0,0 +1,11 @@
[tox]
isolated_build = True
envlist = py310
[testenv]
deps =
black
pytest
commands =
black --check bopytex
pytest .