Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 3 commits into from
Dec 1, 2016

Conversation

matthew-brett
Copy link
Contributor

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.

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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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+.

Copy link
Contributor Author

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.

Copy link
Member

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()
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) - done.

@tacaswell tacaswell changed the title MAINT: TkAgg default backend depends on tkinter [MRG+1] MAINT: TkAgg default backend depends on tkinter Nov 29, 2016
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Nov 29, 2016
Indentation to distinguish clauses in the if conditional from the if
block.
@NelleV NelleV changed the title [MRG+1] MAINT: TkAgg default backend depends on tkinter [MRG+2] MAINT: TkAgg default backend depends on tkinter Nov 29, 2016
Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matthew-brett !

@NelleV
Copy link
Member

NelleV commented Nov 29, 2016

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).

@QuLogic
Copy link
Member

QuLogic commented Nov 29, 2016

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.
@tacaswell tacaswell merged commit 45e4a46 into matplotlib:master Dec 1, 2016
tacaswell added a commit that referenced this pull request Dec 1, 2016
BLD: TkAgg default backend depends on tkinter
@tacaswell
Copy link
Member

backported to v2.x as 7322046

Thanks for taking on all of this Tk work!

@QuLogic QuLogic changed the title [MRG+2] MAINT: TkAgg default backend depends on tkinter MAINT: TkAgg default backend depends on tkinter Dec 1, 2016
@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0 (style change major release) Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants