Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit30a8bca

Browse files
committed
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.
1 parent9c60c58 commit30a8bca

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

‎lib/matplotlib/backends/backend_macosx.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ def new_figure_manager(num, *args, **kwargs):
231231
"""
232232
Create a new figure manager instance
233233
"""
234-
ifnot_macosx.verify_main_display():
235-
importwarnings
236-
warnings.warn("Python is not installed as a framework. The MacOSX "
237-
"backend may not work correctly if Python is not "
238-
"installed as a framework. Please see the Python "
239-
"documentation for more information on installing "
240-
"Python as a framework on Mac OS X")
241234
FigureClass=kwargs.pop('FigureClass',Figure)
242235
figure=FigureClass(*args,**kwargs)
243236
returnnew_figure_manager_given_figure(num,figure)

‎src/_macosx.m

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5707,18 +5707,6 @@ - (int)index
57075707
return Py_None;
57085708
}
57095709

5710-
static PyObject*
5711-
verify_main_display(PyObject* self)
5712-
{
5713-
CGDirectDisplayID display =CGMainDisplayID();
5714-
if (display ==0) {
5715-
PyErr_SetString(PyExc_RuntimeError,"Failed to obtain the display ID of the main display");
5716-
returnNULL;
5717-
}
5718-
Py_INCREF(Py_True);
5719-
return Py_True;
5720-
}
5721-
57225710
typedefstruct {
57235711
PyObject_HEAD
57245712
CFRunLoopTimerRef timer;
@@ -5928,11 +5916,6 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
59285916
METH_VARARGS,
59295917
"Sets the active cursor."
59305918
},
5931-
{"verify_main_display",
5932-
(PyCFunction)verify_main_display,
5933-
METH_NOARGS,
5934-
"Verifies if the main display can be found. This function fails if Python is not built as a framework."
5935-
},
59365919
{NULL,NULL,0,NULL}/* sentinel*/
59375920
};
59385921

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

59575940
voidinit_macosx(void)
59585941
#endif
5959-
{ PyObject *module;
5942+
{
59605943

5944+
#ifdef WITH_NEXT_FRAMEWORK
5945+
PyObject *module;
59615946
import_array();
59625947

59635948
if (PyType_Ready(&GraphicsContextType) <0
@@ -6001,4 +5986,21 @@ void init_macosx(void)
60015986
#if PY3K
60025987
return module;
60035988
#endif
5989+
#else
5990+
/* WITH_NEXT_FRAMEWORK is not defined. This means that Python is not
5991+
* installed as a framework, and therefore the Mac OS X backend will
5992+
* not interact properly with the window manager.
5993+
*/
5994+
PyErr_SetString(PyExc_RuntimeError,
5995+
"Python is not installed as a framework. The Mac OS X backend will"
5996+
"not be able to function correctly if Python is not installed as a"
5997+
"framework. See the Python documentation for more information on"
5998+
"installing Python as a framework on Mac OS X. Please either reinstall"
5999+
"Python as a framework, or try one of the other backends.");
6000+
#if PY3K
6001+
returnNULL;
6002+
#else
6003+
return;
6004+
#endif
6005+
#endif
60046006
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp