This release is a pre-release and may not be stable for production use.
retex for Python
Compile LaTeX documents from Python, to PDF, SVG, ODT, ODP, HTML and Markdown, with retex, a TeX engine written in Rust whose output is pixel-identical to LuaLaTeX's. retex runs in the Python process: no TeX program is started.
import retex
tex = retex.Retex()
doc = tex(r"""
\documentclass{article}
\begin{document}
Hello, \LaTeX{} from Python! $e^{i\pi} + 1 = 0$
\end{document}
""")
pdf = doc.to_pdf() # bytes
svg = doc.to_svg() # str: every page, stacked
odt = doc.to_odt() # bytes
html = doc.to_html() # str: one file, fonts and pictures in it
md = doc.to_markdown() # str
doc.save("hello.pdf") # or .svg, .odt, .odp, .html, .md
A build runs every pass the document needs, BibTeX, biber and makeindex
included. What it reported is in doc.diagnostics, doc.errors and
doc.warnings; a build that writes no output raises retex.RetexError,
whose diagnostics and log say why. In Jupyter, a document shows as
its pages.
Options, all keyword arguments of Retex:
| option | meaning |
|---|---|
passes |
at most this many passes (default 5; 1 runs TeX once) |
shell_escape |
let \write18 run programs (default False) |
accessible |
tagged PDF, checked for accessibility (PDF/UA-2) |
working_dir |
where the document's own files (pictures, .bib) are |
job_name |
the job name (default document) |
files |
{name: str or bytes}: files the document reads |
keep_files |
keep the build's files (log, .aux) in this directory |
Retex.compile_file(path) compiles a .tex file, its directory being
the working directory.
retex needs a TeX Live installation (2025 or 2026) for the LaTeX packages and fonts. Builds release the GIL; they run one at a time in a process, and change the current directory while they run.
Build the wheel with maturin: maturin build --release in this directory; cargo xtask python builds it and runs
tests/. For PyPI, a manylinux wheel: maturin build --release --zig --compatibility manylinux_2_28 (with zig on
PATH).
Metadata
Release files for retex 1.7.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retex-1.7.0a1-cp39-abi3-manylinux_2_28_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ x86-64 | Details for retex-1.7.0a1-cp39-abi3-manylinux_2_28_x86_64.whl |
Release files / retex-1.7.0a1-cp39-abi3-manylinux_2_28_x86_64.whl
| Download URL | retex-1.7.0a1-cp39-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3cfc7739cbd449310ee2690258cc1c1bde2bf813b3497373d9be7bd4c3ee80cc
|
|
BLAKE2b-256 checksum How to use checksums |
c7695daa7c6279d758749b5891b8db9838c815e1eb173ded86e44fac1372965d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for retex 1.7.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.