From 5e858a6ec3097bae6527a2c5e85a5228ef81630d Mon Sep 17 00:00:00 2001 From: ImportanceOfBeingErnest Date: Thu, 26 Apr 2018 17:15:04 +0200 Subject: [PATCH] pillow-dependency update --- INSTALL.rst | 4 ++-- lib/matplotlib/backend_bases.py | 7 ++++++- lib/matplotlib/backends/backend_agg.py | 7 +++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/INSTALL.rst b/INSTALL.rst index e798e1fedf39..bb2402ede7da 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -142,7 +142,7 @@ Matplotlib requires the following dependencies: * `pytz `__ * FreeType (>= 2.3) * `cycler `__ (>= 0.10.0) - * `six `_ + * `six `_ (>= 1.10) * `kiwisolver `__ (>= 1.0.0) Optionally, you can also install a number of packages to enable better user @@ -166,7 +166,7 @@ etc., you can install the following: `_: for saving movies; * `ImageMagick `_: for saving animated gifs; - * `Pillow `_ (>=2.0): for a larger selection of + * `Pillow `_ (>=3.4): for a larger selection of image file formats: JPEG, BMP, and TIFF image files; * `LaTeX `_ and `GhostScript `_ (for rendering text with LaTeX). diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 2e7499a7758a..5e9aed3cf332 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -55,7 +55,12 @@ try: from PIL import Image - _has_pil = True + from PIL import PILLOW_VERSION + from distutils.version import LooseVersion + if LooseVersion(PILLOW_VERSION) >= LooseVersion("3.4"): + _has_pil = True + else: + _has_pil = False del Image except ImportError: _has_pil = False diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index bf4b85032a80..1cfa726b7851 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -42,11 +42,10 @@ from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg from matplotlib import _png -try: +from matplotlib.backend_bases import _has_pil + +if _has_pil: from PIL import Image - _has_pil = True -except ImportError: - _has_pil = False backend_version = 'v2.2'