Skip to content

Using a stricter check to see if Python was installed as a framework. #1613

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 1 commit into from
Jan 10, 2013
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
7 changes: 0 additions & 7 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,6 @@ def new_figure_manager(num, *args, **kwargs):
"""
Create a new figure manager instance
"""
if not _macosx.verify_main_display():
import warnings
warnings.warn("Python is not installed as a framework. The MacOSX "
"backend may not work correctly if Python is not "
"installed as a framework. Please see the Python "
"documentation for more information on installing "
"Python as a framework on Mac OS X")
FigureClass = kwargs.pop('FigureClass', Figure)
figure = FigureClass(*args, **kwargs)
return new_figure_manager_given_figure(num, figure)
Expand Down
38 changes: 20 additions & 18 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -5707,18 +5707,6 @@ - (int)index
return Py_None;
}

static PyObject*
verify_main_display(PyObject* self)
{
CGDirectDisplayID display = CGMainDisplayID();
if (display == 0) {
PyErr_SetString(PyExc_RuntimeError, "Failed to obtain the display ID of the main display");
return NULL;
}
Py_INCREF(Py_True);
return Py_True;
}

typedef struct {
PyObject_HEAD
CFRunLoopTimerRef timer;
Expand Down Expand Up @@ -5928,11 +5916,6 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
METH_VARARGS,
"Sets the active cursor."
},
{"verify_main_display",
(PyCFunction)verify_main_display,
METH_NOARGS,
"Verifies if the main display can be found. This function fails if Python is not built as a framework."
},
{NULL, NULL, 0, NULL}/* sentinel */
};

Expand All @@ -5956,8 +5939,10 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)

void init_macosx(void)
#endif
{ PyObject *module;
{

#ifdef WITH_NEXT_FRAMEWORK
PyObject *module;
import_array();

if (PyType_Ready(&GraphicsContextType) < 0
Expand Down Expand Up @@ -6001,4 +5986,21 @@ void init_macosx(void)
#if PY3K
return module;
#endif
#else
/* WITH_NEXT_FRAMEWORK is not defined. This means that Python is not
* installed as a framework, and therefore the Mac OS X backend will
* not interact properly with the window manager.
*/
PyErr_SetString(PyExc_RuntimeError,
"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 "
"framework. See the Python documentation for more information on "
"installing Python as a framework on Mac OS X. Please either reinstall "
"Python as a framework, or try one of the other backends.");
#if PY3K
return NULL;
#else
return;
#endif
#endif
}