MAINT: TkAgg default backend depends on tkinter#7530
MAINT: TkAgg default backend depends on tkinter#7530tacaswell merged 3 commits intomatplotlib:masterfrom
Conversation
We now always build the TkAgg backend, because it does not depend on the Tk libraries being on the building system. This had the unwanted effect of making the TkAgg backend be the default even if Python tkinter libraries were not installed. Make a `runtime_check` function for the optional packages, that gives True if the package can be used at run time, and use that to reject TkAgg as default backend when tkinter not available.
setupext.py
Outdated
| """ | ||
| pkg_name = 'tkinter' if PY3min else 'Tkinter' | ||
| try: | ||
| __import__(pkg_name) |
There was a problem hiding this comment.
how far back can we use importlib?
There was a problem hiding this comment.
__import__ available in 2.6, I just checked.
There was a problem hiding this comment.
I think you're right - but maybe worth noting that I'm not using importlib, only the __import__ builtin.
There was a problem hiding this comment.
If importlib is in 2.7 can we use that instead of __import__/
setup.py
Outdated
| if default_backend is None: | ||
| default_backend = package.name | ||
| if (isinstance(package, setupext.OptionalBackendPackage) | ||
| and package.runtime_check() |
There was a problem hiding this comment.
🚲 🏠 can you add an extra 4 spaces to these two lines so the conditional and the code can be separated?
Indentation to distinguish clauses in the if conditional from the if block.
|
I don't think the indentation change you've made are pep8 compliant (I am not entirely sure on that, so let's wait for the tests). |
|
The indentation looks correct to me, but the binary operator should be before the break. |
Use importlib to test module import. Put 'and' at end of line instead of beginning.
BLD: TkAgg default backend depends on tkinter
|
backported to v2.x as 7322046 Thanks for taking on all of this Tk work! |
We now always build the TkAgg backend, because it does not depend on the
Tk libraries being on the building system.
This had the unwanted effect of making the TkAgg backend be the default
even if Python tkinter libraries were not installed.
Make a
runtime_checkfunction for the optional packages, that givesTrue if the package can be used at run time, and use that to reject
TkAgg as default backend when tkinter not available.