guix_mirror_bot pushed a commit to branch python-team
in repository guix.

commit a95aa76cc3dddd12b5e786234b31617e74a2885d
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Thu Dec 4 21:23:05 2025 +0900

    gnu: python-matplotlib: Update to 3.10.8.
    
    * gnu/packages/python-xyz.scm (python-matplotlib): Update to 3.10.8.
    [source]: Fetch from git and delete patches.
    [#:configure-flags]: New argument.
    [#:test-flags]: Consolidate all test arguments here, adding "-n" and
    "--pyargs". Update skipped tests regexps.
    [#:phases] {fix-and-disable-failing-tests}: Rename to...
    {patch-commands}: ... this, and streamline phase.
    {patch-dlopen}: Update patched file name.
    {configure-environment}: Streamline.
    {chdir}: New phase.
    [native-inputs]: Add meson-python.
    * gnu/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch:
    Delete file.
    * gnu/local.mk (dist_patch_DATA): De-register it.
    
    Change-Id: Ib002aae96559efa625d2059c783536f77f4170a5
    Signed-off-by: Sharlatan Hellseher <[email protected]>
---
 gnu/local.mk                                       |   1 -
 ...ython-matplotlib-fix-legend-loc-best-test.patch |  84 -------------
 gnu/packages/python-xyz.scm                        | 140 +++++++--------------
 3 files changed, 48 insertions(+), 177 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 1cd704e443..93f3505894 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2054,7 +2054,6 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/python-gpg-setup-72.patch                \
   %D%/packages/patches/python-hdmedians-replace-nose.patch     \
   %D%/packages/patches/python-louvain-fix-test.patch           \
-  %D%/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch        
\
   %D%/packages/patches/python-mohawk-pytest.patch      \
   %D%/packages/patches/python-msal-requests.patch      \
   %D%/packages/patches/python-norns-nose.patch                 \
diff --git 
a/gnu/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch 
b/gnu/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch
deleted file mode 100644
index 9046eb2b4c..0000000000
--- a/gnu/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From 3cc6610597ee16a0cce39f7b033ae529972177e7 Mon Sep 17 00:00:00 2001
-From: Elliott Sales de Andrade <[email protected]>
-Date: Thu, 10 Aug 2023 00:09:53 -0400
-Subject: [PATCH] TST: Improve test for Legend(loc='best') warning
-
-By patching the timer instead of using actually large data, we can both
-a) speed up these tests (~7.5s vs <0.2s for both), and b) consistently
-trigger the warning even on systems which are fast (such as the M1
-systems on Cirrus.)
-
-Also, copy the test data from `test_legend_auto3`, which correctly hits
-all candidate locations for the 'best' legend locator without having to
-fill up the entire Axes with data.
----
- lib/matplotlib/tests/test_legend.py | 38 ++++++++++++++++++++---------
- 1 file changed, 27 insertions(+), 11 deletions(-)
-
-diff --git a/lib/matplotlib/tests/test_legend.py 
b/lib/matplotlib/tests/test_legend.py
-index 759ac6aadaff..1549354ba56b 100644
---- a/lib/matplotlib/tests/test_legend.py
-+++ b/lib/matplotlib/tests/test_legend.py
-@@ -1,5 +1,7 @@
- import collections
-+import itertools
- import platform
-+import time
- from unittest import mock
- import warnings
- 
-@@ -1109,29 +1111,43 @@ def test_usetex_no_warn(caplog):
-     assert "Font family ['serif'] not found." not in caplog.text
- 
- 
--def test_warn_big_data_best_loc():
-+def test_warn_big_data_best_loc(monkeypatch):
-+    # Force _find_best_position to think it took a long time.
-+    counter = itertools.count(0, step=1.5)
-+    monkeypatch.setattr(time, 'perf_counter', lambda: next(counter))
-+
-     fig, ax = plt.subplots()
-     fig.canvas.draw()  # So that we can call draw_artist later.
--    for idx in range(1000):
--        ax.plot(np.arange(5000), label=idx)
-+
-+    # Place line across all possible legend locations.
-+    x = [0.9, 0.1, 0.1, 0.9, 0.9, 0.5]
-+    y = [0.95, 0.95, 0.05, 0.05, 0.5, 0.5]
-+    ax.plot(x, y, 'o-', label='line')
-+
-     with rc_context({'legend.loc': 'best'}):
-         legend = ax.legend()
--    with pytest.warns(UserWarning) as records:
-+    with pytest.warns(UserWarning,
-+                      match='Creating legend with loc="best" can be slow with 
large '
-+                      'amounts of data.') as records:
-         fig.draw_artist(legend)  # Don't bother drawing the lines -- it's 
slow.
-     # The _find_best_position method of Legend is called twice, duplicating
-     # the warning message.
-     assert len(records) == 2
--    for record in records:
--        assert str(record.message) == (
--            'Creating legend with loc="best" can be slow with large '
--            'amounts of data.')
- 
- 
--def test_no_warn_big_data_when_loc_specified():
-+def test_no_warn_big_data_when_loc_specified(monkeypatch):
-+    # Force _find_best_position to think it took a long time.
-+    counter = itertools.count(0, step=1.5)
-+    monkeypatch.setattr(time, 'perf_counter', lambda: next(counter))
-+
-     fig, ax = plt.subplots()
-     fig.canvas.draw()
--    for idx in range(1000):
--        ax.plot(np.arange(5000), label=idx)
-+
-+    # Place line across all possible legend locations.
-+    x = [0.9, 0.1, 0.1, 0.9, 0.9, 0.5]
-+    y = [0.95, 0.95, 0.05, 0.05, 0.5, 0.5]
-+    ax.plot(x, y, 'o-', label='line')
-+
-     legend = ax.legend('best')
-     fig.draw_artist(legend)  # Check that no warning is emitted.
- 
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 32808df6ec..6b061081fb 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -11742,42 +11742,51 @@ comparison.
 (define-public python-matplotlib
   (package
     (name "python-matplotlib")
-    (version "3.8.2")
+    (version "3.10.8")
     (source
      (origin
-       (method url-fetch)
-       (uri (pypi-uri "matplotlib" version))
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://github.com/matplotlib/matplotlib";)
+              (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
        (sha256
-        (base32 "18amhxyxa6yzy1nwky4ggdgvvxnbl3qz2lki05vfx0dqf6w7ia81"))
-       (patches (search-patches 
"python-matplotlib-fix-legend-loc-best-test.patch"))))
+        (base32 "1rlday52hcyrp7xfbdf4z8lzgnxkpfvjxnl9qmq0jvc3ph3n8k5i"))))
     (build-system pyproject-build-system)
     (arguments
      (list
+      #:configure-flags
+      ''(("setup-args" . #("-DrcParams-backend=TkAgg"
+                           "-Dsystem-freetype=true"
+                           "-Dsystem-qhull=true"))
+         ("install-args" . "--tags=data,python-runtime,runtime,tests"))
       #:test-flags
-      '(list "-m" "not network"
-        "-k" (string-join
-              (list
-               ;; This one fails with a small difference in the upper left.
-               "not test_figure_legend_outside"
-               "test_warn_big_data_best_loc"
-               ;; The 'test_lazy_auto_backend_selection' fails because it
-               ;; would require an X server; skip it.
-               "test_lazy_auto_backend_selection"
-               ;; It fails with deprecation warning The register_cmap function
-               ;; was deprecated in Matplotlib 3.7 and will be removed two
-               ;; minor releases later.
-               "test_double_register_builtin_cmap"
-               ;; Failed: DID NOT WARN. No warnings of type (<class
-               ;; 'UserWarning'>,) were emitted.
-               "test_rcparams_update"
-               "test_rcparams_init"
-               ;; ResourceWarning: unclosed file <_io.BufferedWriter
-               ;; name='a.pdf'>
-               "test_multipage_keep_empty"
-               ;; UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from
-               ;; current font.
-               "test_mathtext_ticks")
-              " and not "))
+      #~(list "-m" "not network"
+              "-n" (number->string (parallel-job-count))
+              ;; Run the installed tests, which is what we want since not
+              ;; everything gets built in the source directory.
+              "--pyargs" "matplotlib"
+              "-k"
+              (string-join
+               (list
+                ;; XXX: Disable all image comparison tests because we're using
+                ;; a newer version of FreeType than matplotlib expects.  This
+                ;; leads to minor differences throughout the tests.
+                "not image_comparison"
+                "check_figures_equal"
+                "png"                   ;disables many problematic image tests
+                "test_figure_legend_outside"
+                "test_ft2font_get_kerning"
+                "test_normal_axes"
+                "test_get_tightbbox_polar"
+                ;; The invisible line ordering test fails due to a too short
+                ;; timeout (see:
+                ;; <https://github.com/matplotlib/matplotlib/issues/30809>).
+                "test_invisible_Line_rendering"
+                ;; The determinism check test is not deterministic (see:
+                ;; <https://github.com/matplotlib/matplotlib/issues/30360>)
+                "test_determinism_check")
+               " and not "))
       #:phases
       #~(modify-phases %standard-phases
           (add-before 'build 'pretend-version
@@ -11786,78 +11795,24 @@ comparison.
             ;; '0.0.0'.
             (lambda _
               (setenv "SETUPTOOLS_SCM_PRETEND_VERSION" #$version)))
-          (add-after 'unpack 'fix-and-disable-failing-tests
-            ;; XXX: Disable all image comparison tests because we're using a
-            ;; newer version of FreeType than matplotlib expects.  This leads
-            ;; to minor differences throughout the tests.
+          (add-after 'unpack 'patch-commands
             (lambda _
-              (substitute* (append (find-files "lib/matplotlib/tests/"
-                                               "test_.*\\.py$")
-                                   (find-files "lib/mpl_toolkits/tests"
-                                               "test_.*\\.py$"))
-                (("^from matplotlib" match)
-                 (string-append "import pytest\n" match))
-                (("( *)@([^_]+_)*(image_comparison|check_figures_equal)" match
-                  indent)
-                 (string-append indent "@pytest.mark.skip(\
-reason=\"unknown minor image differences\")\n" match)))
               (substitute* "lib/matplotlib/tests/test_animation.py"
-                (("/bin/sh") (which "sh")))
-              (for-each delete-file
-                        ;; test_normal_axes, test_get_tightbbox_polar
-                        '("lib/matplotlib/tests/test_axes.py"
-                          "lib/matplotlib/tests/test_polar.py"
-                          ;; We don't use the webagg backend and this test
-                          ;; forces it.
-                          "lib/matplotlib/tests/test_backend_webagg.py"
-                          ;; test_outward_ticks
-                          "lib/matplotlib/tests/test_tightlayout.py"
-                          ;; test_hidden_axes fails with minor extent
-                          ;; differences, possibly due to the use of a
-                          ;; different version of FreeType.
-                          "lib/matplotlib/tests/test_constrainedlayout.py"
-                          ;; Fontconfig returns no fonts.
-                          "lib/matplotlib/tests/test_font_manager.py"
-                          ;; The images comparison test fails
-                          ;; non-deterministically when run in parallel (see:
-                          ;; 
https://github.com/matplotlib/matplotlib/issues/22992).
-                          "lib/matplotlib/tests/test_compare_images.py"))))
+                (("/bin/sh") (which "sh")))))
           (add-after 'unpack 'patch-dlopen
             (lambda* (#:key inputs #:allow-other-keys)
-              (substitute* "src/_c_internal_utils.c"
+              (substitute* "src/_c_internal_utils.cpp"
                 (("libX11.so.6")
                  (search-input-file inputs "lib/libX11.so.6")))))
           (add-before 'build 'configure-environment
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Fix rounding errors when using the x87 FPU.
               (when (string-prefix? "i686" #$(%current-system))
-                (setenv "CFLAGS" "-ffloat-store"))
-              (call-with-output-file "mplsetup.cfg"
-                (lambda (port)
-                  (format port "\
-[libs]
-system_freetype = true
-system_qhull = true
-
-[rc_options]
-backend=TkAgg
-
-[directories]
-basedirlist = ~a,~a
-
-[packages]
-tests = True~%" #$(this-package-input "tcl") #$(this-package-input "tk"))))))
-          (replace 'check
-            (lambda* (#:key tests? test-flags #:allow-other-keys)
-              (when tests?
-                ;; Step out of the source directory to avoid interference.
-                (with-directory-excursion "/tmp"
-                  ;; Run the installed tests, which is what we want since not
-                  ;; everything gets built in the source directory.
-                  (apply invoke "pytest"
-                         "-n" (number->string (parallel-job-count))
-                         "--pyargs" "matplotlib"
-                         test-flags))))))))
+                (setenv "CFLAGS" "-ffloat-store"))))
+          (add-before 'check 'chdir
+            (lambda _
+              ;; Step out of the source directory to avoid interference.
+              (chdir "/tmp"))))))
     (propagated-inputs
      (list python-contourpy
            python-cycler
@@ -11879,7 +11834,8 @@ tests = True~%" #$(this-package-input "tcl") 
#$(this-package-input "tk"))))))
            tcl
            tk))
     (native-inputs
-     (list pkg-config
+     (list meson-python
+           pkg-config
            pybind11
            python-pytest
            python-pytest-timeout

Reply via email to