8000 Drop pgi support for the GTK3 backend (#13014) · matplotlib/matplotlib@3221c94 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 3221c94

Browse files
lazkatimhoffm
authored andcommitted
Drop pgi support for the GTK3 backend (#13014)
It's incomplete and unmaintained and PyGObject is pip installable now and supports Ubuntu Xenial which is used on Travis-CI. matplotlib should preferably test with things that are actually used by end users.
1 parent 66b3b83 commit 3221c94

File tree

9 files changed

+34
-77
lines changed

9 files changed

+34
-77
lines changed

.travis.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ addons:
2929
- graphviz
3030
- inkscape
3131
- libcairo2
32+
- libcairo2-dev
33+
- libffi-dev
3234
- libgeos-dev
33-
- libgirepository-1.0.1
35+
- libgirepository1.0-dev
3436
- lmodern
3537
- otf-freefont
3638
- pgf
39+
- pkg-config
3740
- texlive-fonts-recommended
3841
- texlive-latex-base
3942
- texlive-latex-extra
@@ -132,10 +135,11 @@ install:
132135
# install was successful by trying to import the toolkit (sometimes, the
133136
# install appears to be successful but shared libraries cannot be loaded at
134137
# runtime, so an actual import is a better check).
135-
python -mpip install --upgrade cairocffi>=0.8 pgi>=0.0.11.2 &&
136-
python -c 'import pgi as gi; gi.require_version("Gtk", "3.0"); from pgi.repository import Gtk' &&
137-
echo 'pgi is available' ||
138-
echo 'pgi is not available'
138+
python -mpip install --upgrade pycairo cairocffi>=0.8
139+
python -mpip install --upgrade PyGObject &&
140+
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
141+
echo 'PyGObject is available' ||
142+
echo 'PyGObject is not available'
139143
python -mpip install --upgrade pyqt5 &&
140144
python -c 'import PyQt5.QtCore' &&
141145
echo 'PyQt5 is available' ||

INSTALL.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ optional Matplotlib backends and the capabilities they provide.
152152
`PySide <https://pypi.org/project/PySide>`_ (>= 1.0.3): for the Qt4-based
153153
backends;
154154
* `PyQt5 <https://pypi.org/project/PyQt5>`_: for the Qt5-based backends;
155-
* `PyGObject <https://pypi.org/project/PyGObject/>`_ or
156-
`pgi <https://pypi.org/project/pgi/>`_ (>= 0.0.11.2): for the GTK3-based
155+
* `PyGObject <https://pypi.org/project/PyGObject/>`_: for the GTK3-based
157156
backends;
158157
* :term:`wxpython` (>= 4): for the WX-based backends;
159158
* `cairocffi <https://cairocffi.readthedocs.io/en/latest/>`_ (>= 0.8) or
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Drop support for ``pgi`` in the GTK3 backends
2+
`````````````````````````````````````````````
3+
``pgi``, an alternative implementation to PyGObject, is no longer supported in
4+
the GTK3 backends. PyGObject should be used instead.

doc/glossary/index.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ Glossary
6767
channel. PDF was designed in part as a next-generation document
6868
format to replace postscript
6969

70-
pgi
71-
`pgi <https://pypi.python.org/pypi/pgi/>` exists as a relatively
72-
new Python wrapper to GTK3 and acts as a pure python alternative to
73-
PyGObject. pgi still exists in its infancy, currently missing many
74-
features of PyGObject. However Matplotlib does not use any of these
75-
missing features.
76-
7770
PyGObject
7871
`PyGObject <http://www.pygtk.org/>`_ provides Python wrappers for the
7972
:term:`GTK` widgets library

lib/matplotlib/backends/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def _get_running_interactive_framework():
3333
or sys.modules.get("PySide.QtGui"))
3434
if QtGui and QtGui.QApplication.instance():
3535
return "qt4"
36-
Gtk = (sys.modules.get("gi.repository.Gtk")
37-
or sys.modules.get("pgi.repository.Gtk"))
36+
Gtk = sys.modules.get("gi.repository.Gtk")
3837
if Gtk and Gtk.main_level():
3938
return "gtk3"
4039
wx = sys.modules.get("wx")

lib/matplotlib/backends/_gtk3_compat.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

lib/matplotlib/backends/backend_cairo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import numpy as np
1313

14-
# cairocffi is more widely compatible than pycairo (in particular pgi only
15-
# works with cairocffi) so try it first.
14+
# cairocffi is more widely compatible than pycairo so try it first.
1615
try:
1716
import cairocffi as cairo
1817
except ImportError:

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,22 @@
1111
from matplotlib.backend_managers import ToolManager
1212
from matplotlib.figure import Figure
1313
from matplotlib.widgets import SubplotTool
14-
from ._gtk3_compat import GLib, GObject, Gtk, Gdk
14+
15+
try:
16+
import gi
17+
except ImportError:
18+
raise ImportError("The GTK3 backends require PyGObject")
19+
20+
try:
21+
# :raises ValueError: If module/version is already loaded, already
22+
# required, or unavailable.
23+
gi.require_version("Gtk", "3.0")
24+
except ValueError as e:
25+
# in this case we want to re-raise as ImportError so the
26+
# auto-backend selection logic correctly skips.
27+
raise ImportError from e
28+
29+
from gi.repository import GLib, GObject, Gtk, Gdk
1530

1631

1732
_log = logging.getLogger(__name__)

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
def _get_testable_interactive_backends():
2020
backends = []
2121
for deps, backend in [
22-
# gtk3agg fails on Travis, needs to be investigated.
23-
# (["cairocffi", "pgi"], "gtk3agg"),
24-
(["cairocffi", "pgi"], "gtk3cairo"),
22+
(["cairo", "gi"], "gtk3agg"),
23+
(["cairo", "gi"], "gtk3cairo"),
2524
(["PyQt5"], "qt5agg"),
2625
(["PyQt5", "cairocffi"], "qt5cairo"),
2726
(["tkinter"], "tkagg"),

0 commit comments

Comments
 (0)
0