#38 Initial EPEL 9 package
Merged 4 months ago by carlwgeorge. Opened 5 months ago by carlwgeorge.
rpms/ carlwgeorge/python-matplotlib epel9-init  into  epel9

@@ -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

+ 

file modified
+11 -1
@@ -49,7 +49,7 @@ 

  Name:           python-matplotlib

  Version:        3.4.3

  %global Version 3.4.3

- Release:        2%{?dist}

+ Release:        3%{?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 @@ 

  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 @@ 

  %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,9 @@ 

  

  

  %changelog

+ * 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

  

After a good bit of research, to get an EPEL 9 package of python-matplotlib I determined that we'll need to start with version 3.4.3 from the f34 branch. Before opening this PR I fast-forward merged f34 to epel9 to avoid this PR having 290+ commits. One additional changes was needed to get this to build, namely backporting an upstream commit to fix compatibility with Pillow 9.1. Once merged and built this will resolve rhbz#2041315. This won't be able to be built until rpms/python-pikepdf#6 is built and available.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/b6e0969b1ff64f4daed8960e5f9068d1

Pull-Request has been merged by carlwgeorge

4 months ago