Cannot import ligo-followup-advocate with jinja2>=3.0.0
Attempting to import ligo.followup_advocate
with using jinja2=3.0.x results in a ValueError
:
$ python -c "import ligo.followup_advocate"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/duncan/opt/miniconda3/envs/py39/lib/python3.9/site-packages/ligo/followup_advocate/__init__.py", line 19, in <module>
from .jinja import env
File "/home/duncan/opt/miniconda3/envs/py39/lib/python3.9/site-packages/ligo/followup_advocate/jinja.py", line 14, in <module>
loader=jinja2.PackageLoader(__name__, 'templates'),
File "/home/duncan/opt/miniconda3/envs/py39/lib/python3.9/site-packages/jinja2/loaders.py", line 309, in __init__
raise ValueError(
ValueError: The 'ligo.followup_advocate.jinja' package was not installed in a way that PackageLoader understands.
This is because the PackageLoader
is being given the wrong package name - __name__
evaluates to ligo.followup_advocate.jinja
but what PackageLoader
wants is the package that contains the templates/
directory, so should be given ligo.followup_advocate
.
For those interested, the change to jinja2 that causes this issue is https://github.com/pallets/jinja/pull/1169.