Compare commits

...

2 Commits
f34 ... epel9

Author SHA1 Message Date
Orion Poplawski
14b07f66b9 Re-enable wx support (bz#2211203) 2023-07-16 16:16:23 -06:00
Carl George
dd4b1792bc Fix compatibility with Pillow 9.1 2023-04-15 01:36:00 -05:00
2 changed files with 61 additions and 3 deletions

View File

@@ -0,0 +1,45 @@
From edf0b7412cd5cdf6e07f035d542c93033c374b37 Mon Sep 17 00:00:00 2001
From: Thomas A Caswell <tcaswell@gmail.com>
Date: Fri, 1 Apr 2022 11:46:32 -0400
Subject: [PATCH] FIX: account for constant deprecations in Pillow 9.1
https://pillow.readthedocs.io/en/stable/deprecations.html#constants
https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#constants
Image.None -> Image.Dither.None
Image.ADAPTIVE -> Image.Palette.ADAPTIVE
(cherry picked from commit bb997708c08dae01ac95104f1f33d8c08c4715d4)
---
lib/matplotlib/backends/backend_pdf.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py
index 26a12764da..fa7d4a0075 100644
--- a/lib/matplotlib/backends/backend_pdf.py
+++ b/lib/matplotlib/backends/backend_pdf.py
@@ -1646,8 +1646,19 @@ end"""
# Convert to indexed color if there are 256 colors or fewer
# This can significantly reduce the file size
num_colors = len(img_colors)
- img = img.convert(mode='P', dither=Image.NONE,
- palette=Image.ADAPTIVE, colors=num_colors)
+ # These constants were converted to IntEnums and deprecated in
+ # Pillow 9.2
+ dither = (
+ Image.Dither.NONE if hasattr(Image, 'Dither')
+ else Image.NONE
+ )
+ pmode = (
+ Image.Palette.ADAPTIVE if hasattr(Image, 'Palette')
+ else Image.ADAPTIVE
+ )
+ img = img.convert(
+ mode='P', dither=dither, palette=pmode, colors=num_colors
+ )
png_data, bit_depth, palette = self._writePng(img)
if bit_depth is None or palette is None:
raise RuntimeError("invalid PNG header")
--
2.39.2

View File

@@ -10,8 +10,8 @@
%bcond_without qt4
%endif
# No WX for EL8/ELN/EL9
%if 0%{?rhel} >= 8
# No WX for EL8
%if 0%{?rhel} == 8
%bcond_with wx
%else
%bcond_without wx
@@ -49,7 +49,7 @@
Name: python-matplotlib
Version: 3.4.3
%global Version 3.4.3
Release: 2%{?dist}
Release: 4%{?dist}
Summary: Python 2D plotting library
# qt4_editor backend is MIT
# ResizeObserver at end of lib/matplotlib/backends/web_backend/js/mpl.js is Public Domain
@@ -58,6 +58,10 @@ URL: http://matplotlib.org
Source0: https://github.com/matplotlib/matplotlib/archive/v%{Version}/matplotlib-%{Version}.tar.gz
Source1: setup.cfg
# Upstream backported patches
# https://github.com/matplotlib/matplotlib/commit/bb997708c08dae01ac95104f1f33d8c08c4715d4
Patch1: 0001-FIX-account-for-constant-deprecations-in-Pillow-9.1.patch
# Fedora-specific patches; see:
# https://github.com/fedora-python/matplotlib/tree/fedora-patches
# Updated test images for new FreeType.
@@ -312,6 +316,9 @@ Requires: python3-matplotlib%{?_isa} = %{version}-%{release}
%prep
%autosetup -n matplotlib-%{Version} -N
# Upstream backported patches
%patch1 -p1
# Fedora-specific patches follow:
%patch1001 -p1
# Updated test images for new FreeType.
@@ -463,6 +470,12 @@ PYTHONDONTWRITEBYTECODE=1 \
%changelog
* Sun Jul 16 2023 Orion Poplawski <orion@nwra.com> - 3.4.3-4
- Re-enable wx support (bz#2211203)
* Sat Apr 15 2023 Carl George <carl@george.computer> - 3.4.3-3
- Fix compatibility with Pillow 9.1
* Wed Aug 25 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 3.4.3-2
- Fix return type in get_data_path patch