Skip to content

Commit 721fc04

Browse files
authored
Merge pull request #11504 from anntzer/pgi
Bump pgi requirement to 0.0.11.2.
2 parents 7935efc + c59f1b7 commit 721fc04

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ install:
129129
# install was successful by trying to import the toolkit (sometimes, the
130130
# install appears to be successful but shared libraries cannot be loaded at
131131
# runtime, so an actual import is a better check).
132-
python -mpip install cairocffi pgi &&
132+
python -mpip install --upgrade cairocffi>=0.8 pgi>=0.0.11.2 &&
133133
python -c 'import pgi as gi; gi.require_version("Gtk", "3.0"); from pgi.repository import Gtk' &&
134134
echo 'pgi is available' ||
135135
echo 'pgi is not available'
136-
python -mpip install pyqt5 &&
136+
python -mpip install --upgrade pyqt5 &&
137137
python -c 'import PyQt5.QtCore' &&
138138
echo 'PyQt5 is available' ||
139139
echo 'PyQt5 is not available'
140-
python -mpip install -U \
140+
python -mpip install --upgrade \
141141
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \
142142
wxPython &&
143143
python -c 'import wx' &&

INSTALL.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ Optionally, you can also install a number of packages to enable better user
149149
interface toolkits. See :ref:`what-is-a-backend` for more details on the
150150
optional Matplotlib backends and the capabilities they provide.
151151

152-
* :term:`tk` (>= 8.3, != 8.6.0 or 8.6.1): for the TkAgg backend;
152+
* :term:`tk` (>= 8.3, != 8.6.0 or 8.6.1): for the Tk-based backends;
153153
* `PyQt4 <https://pypi.python.org/pypi/PyQt4>`_ (>= 4.4) or
154-
`PySide <https://pypi.python.org/pypi/PySide>`_: for the Qt4Agg backend;
155-
* `PyQt5 <https://pypi.python.org/pypi/PyQt5>`_: for the Qt5Agg backend;
156-
* :term:`wxpython` (>= 4): for the WX or WXAgg backend;
157-
* `cairocffi <https://cairocffi.readthedocs.io/en/latest/>`_ (>=0.8) or
154+
`PySide <https://pypi.python.org/pypi/PySide>`_: for the Qt4-based backends;
155+
* `PyQt5 <https://pypi.python.org/pypi/PyQt5>`_: for the Qt5-based backends;
156+
* `PyGObject <https://pypi.org/project/PyGObject/>`_ or
157+
`pgi <https://pypi.org/project/pgi/>`_ (>= 0.0.11.2): for the GTK3-based
158+
backends;
159+
* :term:`wxpython` (>= 4): for the WX-based backends;
160+
* `cairocffi <https://cairocffi.readthedocs.io/en/latest/>`_ (>= 0.8) or
158161
`pycairo <https://pypi.python.org/pypi/pycairo>`_: for the cairo-based
159-
backends (the latter is required for GTK3Cairo);
162+
backends;
160163
* `Tornado <https://pypi.python.org/pypi/tornado>`_: for the WebAgg backend;
161164

162165
For better support of animation output format and image file formats, LaTeX,
@@ -166,7 +169,7 @@ etc., you can install the following:
166169
<https://libav.org/avconv.html>`_: for saving movies;
167170
* `ImageMagick <https://www.imagemagick.org/script/index.php>`_: for saving
168171
animated gifs;
169-
* `Pillow <https://pillow.readthedocs.io/en/latest/>`_ (>=3.4): for a larger
172+
* `Pillow <https://pillow.readthedocs.io/en/latest/>`_ (>= 3.4): for a larger
170173
selection of image file formats: JPEG, BMP, and TIFF image files;
171174
* `LaTeX <https://miktex.org/>`_ and `GhostScript
172175
<https://ghostscript.com/download/>`_ (for rendering text with LaTeX).

lib/matplotlib/backends/_gtk3_compat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
try:
2626
import pgi as gi
2727
except ImportError:
28-
raise ImportError("The Gtk3 backend requires PyGObject or pgi")
28+
raise ImportError("The GTK3 backends require PyGObject or pgi")
2929

3030
from .backend_cairo import cairo # noqa
3131
# The following combinations are allowed:
@@ -38,6 +38,8 @@
3838
if gi.__name__ == "pgi" and cairo.__name__ == "cairo":
3939
raise ImportError("pgi and pycairo are not compatible")
4040

41+
if gi.__name__ == "pgi" and gi.version_info < (0, 0, 11, 2):
42+
raise ImportError("The GTK3 backends are incompatible with pgi<0.0.11.2")
4143
gi.require_version("Gtk", "3.0")
4244
globals().update(
4345
{name:

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
def _get_testable_interactive_backends():
1919
backends = []
20-
for deps, backend in [(["cairocffi", "pgi"], "gtk3agg"),
20+
# gtk3agg fails on Travis, needs to be investigated.
21+
for deps, backend in [ # (["cairocffi", "pgi"], "gtk3agg"),
2122
(["cairocffi", "pgi"], "gtk3cairo"),
2223
(["PyQt5"], "qt5agg"),
2324
(["cairocffi", "PyQt5"], "qt5cairo"),
@@ -36,16 +37,15 @@ def _get_testable_interactive_backends():
3637
return backends
3738

3839

39-
# 1. Using a timer not only allows testing of timers (on other backends), but
40-
# is also necessary on gtk3 and wx, where a direct call to
41-
# key_press_event("q") from draw_event causes breakage due to the canvas
42-
# widget being deleted too early.
43-
# 2. On gtk3, we cannot even test the timer setup (on Travis, which uses pgi)
44-
# due to https://github.com/pygobject/pgi/issues/45. So we just cleanly
45-
# exit from the draw_event.
40+
# Using a timer not only allows testing of timers (on other backends), but is
41+
# also necessary on gtk3 and wx, where a direct call to key_press_event("q")
42+
# from draw_event causes breakage due to the canvas widget being deleted too
43+
# early. Also, gtk3 redefines key_press_event with a different signature, so
44+
# we directly invoke it from the superclass instead.
4645
_test_script = """\
4746
import sys
4847
from matplotlib import pyplot as plt, rcParams
48+
from matplotlib.backend_bases import FigureCanvasBase
4949
rcParams.update({
5050
"webagg.open_in_browser": False,
5151
"webagg.port_retries": 1,
@@ -54,13 +54,10 @@ def _get_testable_interactive_backends():
5454
fig, ax = plt.subplots()
5555
ax.plot([0, 1], [2, 3])
5656
57-
if rcParams["backend"].startswith("GTK3"):
58-
fig.canvas.mpl_connect("draw_event", lambda event: sys.exit(0))
59-
else:
60-
timer = fig.canvas.new_timer(1)
61-
timer.add_callback(fig.canvas.key_press_event, "q")
62-
# Trigger quitting upon draw.
63-
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
57+
timer = fig.canvas.new_timer(1)
58+
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
59+
# Trigger quitting upon draw.
60+
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
6461
6562
plt.show()
6663
"""

0 commit comments

Comments
 (0)