Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running translations extract with legacy Jinja2 extensions #1179

Closed
sabius opened this issue Sep 6, 2021 · 2 comments
Closed

Comments

@sabius
Copy link

sabius commented Sep 6, 2021

Hi.

After updating Grow from Python2 to 2.0.5's Python3, there's an issue with legacy extensions when running grow translations extract with the message:

ModuleNotFoundError: No module named 'extensions'

This is when setting up custom extensions in the jinja2 key in the extensions of the podspec in the way:

extensions:
  jinja2:
  - extensions.kintaro.KintaroExtension

A temporary workaround for the translations extract is to comment out the jinja2 node. Is there a suggested way to add legacy extensions that work with the translations extract process? Otherwise this might be an issue with the translations extract after upgrading to Python3.

Thanks.

@sabius sabius changed the title Translations extract and legacy Jinja2 extensions Error when running translations extract with legacy Jinja2 extensions Sep 6, 2021
@jeremydw
Copy link
Member

jeremydw commented Sep 6, 2021

I was able to reproduce this on a project using the Blogger extension; will investigate.

Traceback (most recent call last):
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/bin/grow", line 51, in <module>
    group.grow()
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/grow/commands/subcommands/translations_extract.py", line 62, in translations_extract
    catalogs.extract(include_obsolete=include_obsolete, localized=localized,
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/grow/translations/catalog_holder.py", line 363, in extract
    _babel_extract(doc_body, doc_locales, doc.pod_path)
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/grow/translations/catalog_holder.py", line 297, in _babel_extract
    for parts in all_parts:
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/babel/messages/extract.py", line 325, in extract
    for lineno, funcname, messages, comments in results:
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/jinja2/ext.py", line 652, in babel_extract
    extensions.add(import_string(extension))
  File "/Users/jeremydw/.local/share/virtualenvs/project-7m_dr9QI/lib/python3.8/site-packages/jinja2/utils.py", line 143, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
ModuleNotFoundError: No module named 'blog'

@jeremydw
Copy link
Member

jeremydw commented Sep 6, 2021

Thanks for reporting this; just pushed a fix in grow 2.0.6.

Steps to fix it:

  1. Update your Pipfile to include:
[packages]
grow = "==2.0.6"
  1. Run pipenv --rm
  2. Run pipenv install
  3. Run pipenv run grow translations extract

Finally, ensure you've run pipenv run grow install prior to running (4) above to install the Kintaro extension. And if you're using local extensions, place them in the ext folder within your pod.

@jeremydw jeremydw closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants