Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Mako should declare what extra dependencies are required for the custom gettext message extractors #304
Mako provides gettext message extractors for lingua and Babel. They are declared as setuptools entry points. Such entry points can and should specify a list of 'extras': third-party dependencies that should be installed in order to use these custom entry points.
See for example issue wichert/lingua#94:
See the setuptools documentation on "Dynamic Discovery of Services and Plugins" for details.
OK that answer is not enough information - Mako only imports Babel in the Babel plugin which is not referenced anywhere else. in your stack trace at wichert/lingua#94, we see that lingua is not necessarily importing babel, but it is in fact calling upon it:
above is where lingua has a depedendency on babel. But it's not an "import" dependency, it's a set of dependencies at the entrypoint level, not something I've seen before. if lingua is hardcoded to install a babel entrypoint, I guess this could go either way but it still seems like lingua has babel as a pretty strong dependency.
here's the better doc:
now I do have some "extras_require" in some other projects but I've not combined these with entrypoints. When exactly does "Babel" get installed?
My use case looks like this:
This causes the issue presented in wichert/lingua#94.
When the user wants to use it to extract messages in their project. For this to work well whether or not Babel is installed, following changes are required:
This way lingua loads the Mako-for-Babel extractor only if Babel is explicitly installed, for example the user could add
OK by "when does babel get installed" I was more trying to determine the imperative effects of these directives being added. that is, without the directive, right now you're getting I assume the error, "can't find any module called Babel", or something like that (feel free to spell this out for me). and with the directive, what will happen in your case? the paths to this plugin will be silently ignored and your program just proceeds? (since this is all in a debug toolbar you aren't developing anyway)?
Not entirely sure I understand the question, I will try to answer with this, I might still be off-topic though...
In short: with the extra directive lingua gains clearer knowledge of what is going wrong: a dependency is missing as well as its exact name ; and yes, it can then choose to ignore this plugin entirely.
Adding the extras to the entry points (when Babel is not installed), brings us from:
(complete stack traces below ...)
The former is a relatively vague exception, the module name does not actually give viable information about which dependency is missing.
The latter shows clearly that a dependency is missing and what its name is.
In our case it makes sense to let lingua simply ignore the entry points that raise
Alternatively lingua could show the user a warning listing the message extractors that have been ignored and which dependencies should be installed to activate them.
Complete stack traces
Without extras directive:
With extras directive: