Skip to content
Browse files

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

… Also, because of the recurring problems with non-framework Pythons, importing the Mac OS X backend will now fail (instead of just issuing a warning) if Python is not installed as a framework.
  • Loading branch information...
1 parent 9c60c58 commit 30a8bcae4f6fbd976f18c1ebd3543407aa8f1342 @mdehoon mdehoon committed
Showing with 20 additions and 25 deletions.
  1. +0 −7 lib/matplotlib/backends/backend_macosx.py
  2. +20 −18 src/_macosx.m
View
7 lib/matplotlib/backends/backend_macosx.py
@@ -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)
View
38 src/_macosx.m
@@ -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;
@@ -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 */
};
@@ -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
@@ -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
}

0 comments on commit 30a8bca

Please sign in to comment.
Something went wrong with that request. Please try again.