From 42d49114999f2687dec6b91d8a86e5791b997bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 6 Jan 2025 15:46:13 +0100 Subject: [PATCH] Python 3.14 support --- python-matplotlib.spec | 3 ++ python3.14.patch | 84 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 python3.14.patch diff --git a/python-matplotlib.spec b/python-matplotlib.spec index a882255..b882114 100644 --- a/python-matplotlib.spec +++ b/python-matplotlib.spec @@ -65,6 +65,9 @@ Patch0001: 0004-Use-old-stride_windows-implementation-on-32-bit-x86.patch # Temporary fix for some tests. Patch0002: 0005-Partially-revert-TST-Fix-minor-issues-in-interactive.patch +# https://github.com/matplotlib/matplotlib/pull/29393 +Patch0004: python3.14.patch + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: glibc-langpack-en diff --git a/python3.14.patch b/python3.14.patch new file mode 100644 index 0000000..5ca176f --- /dev/null +++ b/python3.14.patch @@ -0,0 +1,84 @@ +From caf65e3e55bbf7d60712beb9053ee51a134608b0 Mon Sep 17 00:00:00 2001 +From: Thomas A Caswell +Date: Tue, 31 Dec 2024 15:08:31 -0500 +Subject: [PATCH] MNT: use copy.deepcopy to implement deepcopy method + +We provide deepcopy and copy methods as a shortcut for users to avoid having to +import the copy module and call the required function. Directly calling +`__deepcopy__` side-steps all of the memoization machinery and may lead to +incorrect results. +--- + lib/matplotlib/path.py | 20 ++++++++++++++++++-- + lib/matplotlib/transforms.py | 8 +++++++- + 2 files changed, 25 insertions(+), 3 deletions(-) + +diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py +index 5f5a0f3..eac8cbd 100644 +--- a/lib/matplotlib/path.py ++++ b/lib/matplotlib/path.py +@@ -11,6 +11,7 @@ visualisation. + + import copy + from functools import lru_cache ++import sys + from weakref import WeakValueDictionary + + import numpy as np +@@ -282,11 +283,26 @@ class Path: + readonly, even if the source `Path` is. + """ + # Deepcopying arrays (vertices, codes) strips the writeable=False flag. +- p = copy.deepcopy(super(), memo) ++ if sys.version_info >= (3, 14): ++ from copy import _reconstruct, _keep_alive ++ rv = super().__reduce_ex__(4) ++ assert memo is not None ++ p = _reconstruct(self, memo, *rv) ++ if memo is not None: ++ memo[id(self)] = p ++ _keep_alive(self, memo) ++ ++ else: ++ p = copy.deepcopy(super(), memo) + p._readonly = False + return p + +- deepcopy = __deepcopy__ ++ def deepcopy(self, memo=None): ++ """ ++ Return a shallow copy of the `Path`, which will share the ++ vertices and codes with the source `Path`. ++ """ ++ return copy.deepcopy(self, memo=memo) + + @classmethod + def make_compound_path_from_polys(cls, XY): +diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py +index 2934b0a..74d3c68 100644 +--- a/lib/matplotlib/transforms.py ++++ b/lib/matplotlib/transforms.py +@@ -38,6 +38,7 @@ of how to use transforms. + import copy + import functools + import itertools ++import sys + import textwrap + import weakref + import math +@@ -141,7 +142,12 @@ class TransformNode: + for k, v in self._parents.items() if v is not None} + + def __copy__(self): +- other = copy.copy(super()) ++ if sys.version_info >= (3, 14): ++ from copy import _reconstruct ++ rv = super().__reduce_ex__(4) ++ other = _reconstruct(self, None, *rv) ++ else: ++ other = copy.copy(super()) + # If `c = a + b; a1 = copy(a)`, then modifications to `a1` do not + # propagate back to `c`, i.e. we need to clear the parents of `a1`. + other._parents = {} +-- +2.48.1 +