Thin wrapper for "TinyTeX" (MIT)
Project description
PyTinyTeX
The easiest way to go from .tex to .pdf in Python. PyTinyTeX wraps TinyTeX — a lightweight, cross-platform, portable LaTeX distribution based on TeX Live — and gives you compilation, package management, and diagnostics from Python or the command line.
import pytinytex
pytinytex.download_tinytex()
result = pytinytex.compile("paper.tex", auto_install=True)
print(result.pdf_path) # paper.pdf
No system-wide TeX installation required. Missing packages are installed automatically.
Installation
pip install pytinytex
Python 3.8+ on Linux, macOS, and Windows.
Quick start
1. Get TinyTeX
import pytinytex
# Download the default variation (variation 1: ~90 common LaTeX packages)
pytinytex.download_tinytex()
# Or pick a variation:
# 0 — infrastructure only, no packages
# 1 — common packages (default)
# 2 — extended package set
pytinytex.download_tinytex(variation=2)
# Track download progress
pytinytex.download_tinytex(progress_callback=lambda downloaded, total: print(f"{downloaded}/{total} bytes"))
2. Compile a document
result = pytinytex.compile("paper.tex")
if result.success:
print("PDF at:", result.pdf_path)
else:
for error in result.errors:
print(f" ! {error.message} (line {error.line})")
Multi-pass compilation for cross-references and TOC:
result = pytinytex.compile("paper.tex", num_runs=2)
Choose your engine:
result = pytinytex.compile("paper.tex", engine="xelatex")
result = pytinytex.compile("paper.tex", engine="lualatex")
3. Auto-install missing packages
The killer feature: if your document needs a package you don't have, PyTinyTeX can find it, install it, and retry — all in one call:
result = pytinytex.compile("paper.tex", auto_install=True)
print(result.installed_packages) # e.g. ['booktabs', 'pgf']
Package management
Full access to the TeX Live package manager (tlmgr):
import pytinytex
pytinytex.install("booktabs")
pytinytex.remove("booktabs")
# List installed packages (returns list of dicts)
for pkg in pytinytex.list_installed():
print(pkg["name"])
# Search for packages
pytinytex.search("amsmath")
# Detailed package info (returns dict)
pytinytex.info("booktabs")
# Update all packages
pytinytex.update()
# TeX Live version
pytinytex.get_version()
Engine discovery
Locate LaTeX engine executables (variation 1+):
pytinytex.get_engine("pdflatex") # full path to the executable
pytinytex.get_engine("xelatex")
pytinytex.get_engine("lualatex")
# Convenience shortcuts
pytinytex.get_pdflatex_engine()
pytinytex.get_xelatex_engine()
pytinytex.get_lualatex_engine()
LaTeX log parser
Parse any LaTeX .log file into structured data — useful even outside PyTinyTeX:
from pytinytex import parse_log
with open("paper.log") as f:
parsed = parse_log(f.read())
for error in parsed.errors:
print(f"{error.file}:{error.line}: {error.message}")
for warning in parsed.warnings:
print(warning.message)
# Missing .sty packages detected automatically
print(parsed.missing_packages) # e.g. ['tikz', 'booktabs']
Health check
Diagnose your TinyTeX installation:
result = pytinytex.doctor()
for check in result.checks:
status = "PASS" if check.passed else "FAIL"
print(f" [{status}] {check.name}: {check.message}")
Checks: TinyTeX installed, PATH configured, tlmgr functional, engine availability.
Command-line interface
Every feature is also available from the terminal:
# Download TinyTeX
pytinytex download
pytinytex download --variation 2
# Compile a document
pytinytex compile paper.tex
pytinytex compile paper.tex --engine xelatex --runs 2 --auto-install
# Package management
pytinytex install booktabs
pytinytex remove booktabs
pytinytex list
pytinytex search amsmath
pytinytex info booktabs
pytinytex update
# Diagnostics
pytinytex doctor
pytinytex version
# Also works as a Python module
python -m pytinytex doctor
Integrating with pypandoc
PyTinyTeX pairs naturally with pypandoc for converting Markdown, HTML, and other formats to PDF:
import pytinytex
import pypandoc
pdflatex_path = pytinytex.get_pdflatex_engine()
pypandoc.convert_file("input.md", "pdf", outputfile="output.pdf",
extra_args=["--pdf-engine", pdflatex_path])
Uninstalling TinyTeX
pytinytex.uninstall() # removes the TinyTeX directory
Or from the CLI:
pytinytex uninstall
Contributing
Contributions are welcome. When opening a PR, please keep the following guidelines in mind:
- Before implementing, please open an issue for discussion.
- Make sure you have tests for the new logic.
- Add yourself to contributors in this README unless you are already there.
Contributors
- Jessica Tegner — Maintainer and original creator of PyTinyTeX
License
PyTinyTeX is available under the MIT license. See LICENSE for more details. TinyTeX itself is available under the GPL-2 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytinytex-0.5.0.tar.gz.
File metadata
- Download URL: pytinytex-0.5.0.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dca1e69136585944ef31569c401d19d854f8cd6adee8b01eccdc6f60a543edf
|
|
| MD5 |
c155182526a3edb5c3d0eb6d04b2fe3e
|
|
| BLAKE2b-256 |
e26234172f85255cb8ffdc5cf12203ef6689e9f38d582498eb3fdd45ebb7e588
|
Provenance
The following attestation bundles were made for pytinytex-0.5.0.tar.gz:
Publisher:
ci.yaml on JessicaTegner/PyTinyTeX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytinytex-0.5.0.tar.gz -
Subject digest:
5dca1e69136585944ef31569c401d19d854f8cd6adee8b01eccdc6f60a543edf - Sigstore transparency entry: 1077248886
- Sigstore integration time:
-
Permalink:
JessicaTegner/PyTinyTeX@b8f5af5f1925531905d282a1ca42ed783ea94b67 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/JessicaTegner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@b8f5af5f1925531905d282a1ca42ed783ea94b67 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytinytex-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pytinytex-0.5.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98ac467aebbeac18cbd5e9c67d3f4500e4d788f23c2ca44f749e1bb8a2ed97f2
|
|
| MD5 |
ee410f9d3f23cfa17a196727d6010b72
|
|
| BLAKE2b-256 |
6f23952bd663bcdcd2a7ef7b1f9576e2a69d910acdbb868a40849012a9721ec4
|
Provenance
The following attestation bundles were made for pytinytex-0.5.0-py3-none-any.whl:
Publisher:
ci.yaml on JessicaTegner/PyTinyTeX
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytinytex-0.5.0-py3-none-any.whl -
Subject digest:
98ac467aebbeac18cbd5e9c67d3f4500e4d788f23c2ca44f749e1bb8a2ed97f2 - Sigstore transparency entry: 1077248907
- Sigstore integration time:
-
Permalink:
JessicaTegner/PyTinyTeX@b8f5af5f1925531905d282a1ca42ed783ea94b67 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/JessicaTegner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@b8f5af5f1925531905d282a1ca42ed783ea94b67 -
Trigger Event:
push
-
Statement type: