-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MAINT: TkAgg default backend depends on tkinter #7530
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
MAINT: TkAgg default backend depends on tkinter #7530
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.
""" | ||
pkg_name = 'tkinter' if PY3min else 'Tkinter' | ||
try: | ||
__import__(pkg_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how far back can we use importlib
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__import__
available in 2.6, I just checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
importlib
is 2.7 and 3.1+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If importlib
is in 2.7 can we use that instead of __import__
/
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚲 🏠 can you add an extra 4 spaces to these two lines so the conditional and the code can be separated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) - done.
Indentation to distinguish clauses in the if conditional from the if block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @matthew-brett !
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_check
function 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.