Skip to content

Commit cdf6f03

Browse files
committed
Add runtime sphinx/jinja version checker.
1 parent 032dbc7 commit cdf6f03

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

numpydoc/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@
55
__version__ = '1.2.2.dev0'
66

77

8+
def _verify_sphinx_jinja():
9+
"""Ensure sphinx and jinja versions are compatible.
10+
11+
Jinja2>=3.1 requires Sphinx>=4.0.2. Raises exception if this condition is
12+
not met.
13+
14+
TODO: This check can be removed when the minimum supported sphinx version
15+
for numpydoc sphinx>=4.0.2
16+
"""
17+
import sphinx, jinja2
18+
from packaging import version
19+
20+
if version.parse(sphinx.__version__) <= version.parse("4.0.2"):
21+
if version.parse(jinja2.__version__) >= version.parse("3.1"):
22+
from sphinx.errors import VersionRequirementError
23+
raise VersionRequirementError(
24+
"\n\nSphinx<4.0.2 is incompatible with Jinja2>=3.1.\n"
25+
"If you wish to continue using sphinx<4.0.2 you need to pin "
26+
"Jinja2<3.1."
27+
)
28+
29+
30+
_verify_sphinx_jinja()
31+
32+
833
def setup(app, *args, **kwargs):
934
from .numpydoc import setup
1035
return setup(app, *args, **kwargs)

0 commit comments

Comments
 (0)