Skip to content

Bump pgi requirement to 0.0.11.2. #11504

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
Jul 13, 2018
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ install:
# install was successful by trying to import the toolkit (sometimes, the
# install appears to be successful but shared libraries cannot be loaded at
# runtime, so an actual import is a better check).
python -mpip install cairocffi pgi &&
python -mpip install --upgrade cairocffi>=0.8 pgi>=0.0.11.2 &&
python -c 'import pgi as gi; gi.require_version("Gtk", "3.0"); from pgi.repository import Gtk' &&
echo 'pgi is available' ||
echo 'pgi is not available'
python -mpip install pyqt5 &&
python -mpip install --upgrade pyqt5 &&
python -c 'import PyQt5.QtCore' &&
echo 'PyQt5 is available' ||
echo 'PyQt5 is not available'
python -mpip install -U \
python -mpip install --upgrade \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \
wxPython &&
python -c 'import wx' &&
Expand Down
17 changes: 10 additions & 7 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ Optionally, you can also install a number of packages to enable better user
interface toolkits. See :ref:`what-is-a-backend` for more details on the
optional Matplotlib backends and the capabilities they provide.

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

For better support of animation output format and image file formats, LaTeX,
Expand All @@ -167,7 +170,7 @@ etc., you can install the following:
<https://libav.org/avconv.html>`_: for saving movies;
* `ImageMagick <https://www.imagemagick.org/script/index.php>`_: for saving
animated gifs;
* `Pillow <https://pillow.readthedocs.io/en/latest/>`_ (>=3.4): for a larger
* `Pillow <https://pillow.readthedocs.io/en/latest/>`_ (>= 3.4): for a larger
selection of image file formats: JPEG, BMP, and TIFF image files;
* `LaTeX <https://miktex.org/>`_ and `GhostScript
<https://ghostscript.com/download/>`_ (for rendering text with LaTeX).
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/backends/_gtk3_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
try:
import pgi as gi
except ImportError:
raise ImportError("The Gtk3 backend requires PyGObject or pgi")
raise ImportError("The GTK3 backends require PyGObject or pgi")

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

if gi.__name__ == "pgi" and gi.version_info < (0, 0, 11, 2):
raise ImportError("The GTK3 backends are incompatible with pgi<0.0.11.2")
gi.require_version("Gtk", "3.0")
globals().update(
{name:
Expand Down
27 changes: 12 additions & 15 deletions lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

def _get_testable_interactive_backends():
backends = []
for deps, backend in [(["cairocffi", "pgi"], "gtk3agg"),
# gtk3agg fails on Travis, needs to be investigated.
for deps, backend in [ # (["cairocffi", "pgi"], "gtk3agg"),
(["cairocffi", "pgi"], "gtk3cairo"),
(["PyQt5"], "qt5agg"),
(["cairocffi", "PyQt5"], "qt5cairo"),
Expand All @@ -34,16 +35,15 @@ def _get_testable_interactive_backends():
return backends


# 1. Using a timer not only allows testing of timers (on other backends), but
# is also necessary on gtk3 and wx, where a direct call to
# key_press_event("q") from draw_event causes breakage due to the canvas
# widget being deleted too early.
# 2. On gtk3, we cannot even test the timer setup (on Travis, which uses pgi)
# due to https://github.com/pygobject/pgi/issues/45. So we just cleanly
# exit from the draw_event.
# Using a timer not only allows testing of timers (on other backends), but is
# also necessary on gtk3 and wx, where a direct call to key_press_event("q")
# from draw_event causes breakage due to the canvas widget being deleted too
# early. Also, gtk3 redefines key_press_event with a different signature, so
# we directly invoke it from the superclass instead.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xref #10836

_test_script = """\
import sys
from matplotlib import pyplot as plt, rcParams
from matplotlib.backend_bases import FigureCanvasBase
rcParams.update({
"webagg.open_in_browser": False,
"webagg.port_retries": 1,
Expand All @@ -53,13 +53,10 @@ def _get_testable_interactive_backends():
ax = fig.add_subplot(111)
ax.plot([0, 1], [2, 3])

if rcParams["backend"].startswith("GTK3"):
fig.canvas.mpl_connect("draw_event", lambda event: sys.exit(0))
else:
timer = fig.canvas.new_timer(1)
timer.add_callback(fig.canvas.key_press_event, "q")
# Trigger quitting upon draw.
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
timer = fig.canvas.new_timer(1)
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
# Trigger quitting upon draw.
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())

plt.show()
"""
Expand Down