sphinx-jinja2-compat
Patches Jinja2 v3 to restore compatibility with earlier Sphinx versions.
What it is and what it does
sphinx-jinja2-compat is a compatibility shim that automatically patches Jinja2 v3 when imported, allowing it to work with Sphinx versions that were built for earlier Jinja2 releases. It also addresses issues where some Sphinx versions fail to run correctly on Python 3.10. The patches are applied transparently at import time and can be disabled by setting the environment variable NO_SPHINX_JINJA2_COMPAT to 1.
The package depends on jinja2, markupsafe, and standard-imghdr, and is designed to integrate seamlessly into Sphinx documentation builds. It's classified as Alpha but is actively maintained and supports Python 3.6 through 3.13, including both CPython and PyPy implementations.
Use it for:
- Fix Sphinx documentation builds that fail after upgrading to Jinja2 v3
- Run Sphinx on Python 3.10 when using Sphinx versions that have compatibility issues
- Maintain documentation builds across multiple Sphinx versions without manual patching
- Ensure legacy Sphinx projects continue to work with modern Jinja2 releases
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Patches Jinja2 v3 to restore compatibility with earlier Sphinx versions and fixes some Sphinx versions on Python 3.10.
Yes, if you are using Sphinx with Jinja2 v3 and encounter compatibility errors, or if you need Sphinx to work on Python 3.10. The package is actively maintained, has no known vulnerabilities, and installs with low friction. Install only if you actually face the compatibility issues it addresses—it's a targeted fix, not a general dependency.
Install
sphinx-jinja2-compat on PyPI
pip
pip install sphinx-jinja2-compatuv
uv add sphinx-jinja2-compatpoetry
poetry add sphinx-jinja2-compatInstalling sphinx-jinja2-compat
Before you install
Low install friction with a pure-Python wheel. Actively maintained as of 2026-07-06 with no known security vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install sphinx-jinja2-compat
import sphinx_jinja2_compat
# Patches are applied automatically on import; disable with NO_SPHINX_JINJA2_COMPAT=1
Verify before relying
- Which specific Sphinx versions benefit from the Jinja2 v3 compatibility patches
- Whether the Python 3.10 fix applies to all Sphinx versions or only specific ones
- Current test coverage and which Sphinx/Jinja2 version combinations are actively tested
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — jinja2, markupsafe, standard-imghdr |
| Maintenance | actively maintained — 373 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 658,656/month — #5,468 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sphinx_jinja2_compat-0.4.1-py3-none-any.whl
Keywords: documentation, jinja2, sphinx
Tags
More Documentation packages
Docutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
griffeGriffe extracts the complete structure and…
permissive · top 1,000 on PyPI
sphinxcontrib-serializinghtmlA Sphinx extension that outputs documentation…
permissive · top 1,000 on PyPI
alabasterAlabaster is a clean, responsive Sphinx theme…
permissive · top 1,000 on PyPI
sphinxcontrib-htmlhelpA Sphinx extension that generates HTML help…
permissive · top 1,000 on PyPI
sphinx-jinjaA Sphinx extension that lets you embed Jinja2…
permissive · top 5,000 on PyPI
django-jinjaIntegrates Jinja2 templating into Django,…
permissive · top 15,000 on PyPI
sphinx-pyprojectLoads Sphinx documentation configuration from…
permissive · top 15,000 on PyPI
jinja2_pluralizeProvides Jinja2 template filters for…
permissive · top 15,000 on PyPI
pyramid-jinja2Integrates the Jinja2 templating engine with…
permissive · top 5,000 on PyPI
sphinx-toolboxSphinx-toolbox extends Sphinx with a collection…
permissive · top 15,000 on PyPI
jinja2-simple-tagsProvides base classes to create custom Jinja2…
permissive · top 5,000 on PyPI
types-Jinja2Provides PEP 561 type stubs for Jinja2,…
permissive · top 5,000 on PyPI
jinja2-timeJinja2 extension that adds template tags for…
permissive · top 5,000 on PyPI
py2neo-historyProvides access to archived versions of the…
permissive · top 15,000 on PyPI