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

lingua tries to use Babel extractors even if Babel is not installed #94

Closed
sinoroc opened this issue Aug 21, 2019 · 3 comments
Closed

Comments

@sinoroc
Copy link
Contributor

sinoroc commented Aug 21, 2019

It appears that lingua tries to use Babel message extractors even if Babel is not installed. For example Mako contains custom message extractors for Babel. If Mako is installed but not Babel, lingua recognizes the Mako-for-Babel message extractors, loads them, and finally fails while tryin to use them.

Two things:

  1. Mako should declare Babel as an extra dependency alongside the entry points for its custom message extractors
  2. lingua should not load entry points when the extra dependencies are missing

See setuptools documentation on "Dynamic Discovery of Services and Plugins" for details.

@sinoroc
Copy link
Contributor Author

sinoroc commented Aug 21, 2019

I am working on fixes for both Mako and lingua.

@sinoroc
Copy link
Contributor Author

sinoroc commented Aug 21, 2019

This is the trace when Mako is installed but not Babel:

Traceback (most recent call last):
  File "/home/user/workspace/project/.tox/develop/bin/pot-create", line 11, in <module>
    sys.exit(main())
  File "/home/user/workspace/project/.tox/develop/lib/python3.6/site-packages/lingua/extract.py", line 308, in main
    register_babel_plugins()
  File "/home/user/workspace/project/.tox/develop/lib/python3.6/site-packages/lingua/extractors/babel.py", line 51, in register_babel_plugins
    extractor = entry_point.load(require=True)
  File "/home/user/workspace/project/.tox/develop/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/home/user/workspace/project/.tox/develop/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/user/workspace/project/.tox/develop/lib/python3.6/site-packages/mako/ext/babelplugin.py", line 8, in <module>
    from babel.messages.extract import extract_python
ModuleNotFoundError: No module named 'babel'

@wichert
Copy link
Owner

wichert commented Nov 10, 2019

Fixed by #97

@wichert wichert closed this as completed Nov 10, 2019
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