Skip to content

FIX: don't import macosx to check if eventloop running #12603

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 2 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/matplotlib/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ def _get_running_interactive_framework():
if frame.f_code == tkinter.mainloop.__code__:
return "tk"
frame = frame.f_back
try:
from matplotlib.backends import _macosx
except ImportError:
pass
else:
if _macosx.event_loop_is_running():
if 'matplotlib.backends._macosx' in sys.modules:
if sys.modules["matplotlib.backends._macosx"].event_loop_is_running():
return "macosx"
if sys.platform.startswith("linux") and not os.environ.get("DISPLAY"):
return "headless"
Expand Down
12 changes: 12 additions & 0 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -2580,9 +2580,21 @@ static bool verify_framework(void)
ProcessSerialNumber psn;
/* These methods are deprecated, but they don't require the app to
have started */
#ifdef COMPILING_FOR_10_6
NSApp = [NSApplication sharedApplication];
NSApplicationActivationPolicy activationPolicy = [NSApp activationPolicy];
switch (activationPolicy) {
case NSApplicationActivationPolicyRegular:
case NSApplicationActivationPolicyAccessory:
return true;
case NSApplicationActivationPolicyProhibited:
break;
}
#else
if (CGMainDisplayID()!=0
&& GetCurrentProcess(&psn)==noErr
&& SetFrontProcess(&psn)==noErr) return true;
#endif
PyErr_SetString(PyExc_ImportError,
"Python is not installed as a framework. The Mac OS X backend will "
"not be able to function correctly if Python is not installed as a "
Expand Down