Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44c0ef5

Browse filesBrowse files
authored
Merge pull request #12633 from Mottl/macos-non-framework-fix
Added support for MacOSX backend for PyPy
2 parents 6a61f93 + db6c8e8 commit 44c0ef5
Copy full SHA for 44c0ef5

File tree

Expand file treeCollapse file tree

2 files changed

+13
-14
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-14
lines changed
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Added support for MacOSX backend for PyPy
2+
-----------------------------------------
3+
4+
Fixed issue with MacOSX backend for PyPy and also for non-framework Python
5+
installations.

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ static void lazy_init(void) {
278278
backend_inited = true;
279279

280280
NSApp = [NSApplication sharedApplication];
281+
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
281282

282283
#ifndef PYPY
284+
/* TODO: remove ifndef after the new PyPy with the PyOS_InputHook implementation
285+
get released: https://bitbucket.org/pypy/pypy/commits/caaf91a */
283286
PyOS_InputHook = wait_for_stdin;
284287
#endif
285288

@@ -2579,26 +2582,13 @@ static void context_cleanup(const void* info)
25792582
Timer_new, /* tp_new */
25802583
};
25812584

2585+
#ifndef COMPILING_FOR_10_6
25822586
static bool verify_framework(void)
25832587
{
25842588
ProcessSerialNumber psn;
2585-
/* These methods are deprecated, but they don't require the app to
2586-
have started */
2587-
#ifdef COMPILING_FOR_10_6
2588-
NSApp = [NSApplication sharedApplication];
2589-
NSApplicationActivationPolicy activationPolicy = [NSApp activationPolicy];
2590-
switch (activationPolicy) {
2591-
case NSApplicationActivationPolicyRegular:
2592-
case NSApplicationActivationPolicyAccessory:
2593-
return true;
2594-
case NSApplicationActivationPolicyProhibited:
2595-
break;
2596-
}
2597-
#else
25982589
if (CGMainDisplayID()!=0
25992590
&& GetCurrentProcess(&psn)==noErr
26002591
&& SetFrontProcess(&psn)==noErr) return true;
2601-
#endif
26022592
PyErr_SetString(PyExc_ImportError,
26032593
"Python is not installed as a framework. The Mac OS X backend will "
26042594
"not be able to function correctly if Python is not installed as a "
@@ -2610,6 +2600,7 @@ static bool verify_framework(void)
26102600
"Matplotlib FAQ for more information.");
26112601
return false;
26122602
}
2603+
#endif
26132604

26142605
static struct PyMethodDef methods[] = {
26152606
{"event_loop_is_running",
@@ -2660,8 +2651,11 @@ static bool verify_framework(void)
26602651
|| PyType_Ready(&TimerType) < 0)
26612652
return NULL;
26622653

2654+
#ifndef COMPILING_FOR_10_6
2655+
/* if >=10.6 invoke setActivationPolicy in lazy_init */
26632656
if (!verify_framework())
26642657
return NULL;
2658+
#endif
26652659

26662660
module = PyModule_Create(&moduledef);
26672661
if (!module)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.