From d75d3a2b39de62342ec77e935e8ae09e489e34f8 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Wed, 7 Feb 2024 20:33:08 -0700 Subject: [PATCH 1/5] Merge pull request #27755 from ksunden/release_gil_macos_event_loop Allow threads during macos event loop (cherry picked from commit b50843d1ceac118ea5e71ef77fc591c8369954f7) --- src/_macosx.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/_macosx.m b/src/_macosx.m index 3e52fdf81459..8022288555f7 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -547,6 +547,8 @@ int mpl_check_modifier( close(channel[0]); } + Py_BEGIN_ALLOW_THREADS + NSDate* date = (timeout > 0.0) ? [NSDate dateWithTimeIntervalSinceNow: timeout] : [NSDate distantFuture]; @@ -559,6 +561,8 @@ int mpl_check_modifier( [NSApp sendEvent: event]; } + Py_END_ALLOW_THREADS + if (py_sigint_handler) { PyOS_setsig(SIGINT, py_sigint_handler); } if (sigint_socket) { CFSocketInvalidate(sigint_socket); } if (!error) { close(channel[1]); } From 240ff81566ddfc6662d051651f7ac64683f7d6ee Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Mon, 4 Sep 2023 13:26:34 -0500 Subject: [PATCH 2/5] Merge pull request #26689 from anntzer/pgferr Fix error generation for missing pgf.texsystem. (cherry picked from commit 5f785e3e19e6d4f4b50958b9dca4cca5b78ecb16) --- lib/matplotlib/backends/backend_pgf.py | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 9d7d77143649..d691da268460 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -286,16 +286,7 @@ def __init__(self): self._finalize_tmpdir = weakref.finalize(self, self._tmpdir.cleanup) # test the LaTeX setup to ensure a clean startup of the subprocess - try: - self._setup_latex_process(expect_reply=False) - except FileNotFoundError as err: - raise RuntimeError( - f"{self.latex.args[0]!r} not found. Install it or change " - f"rcParams['pgf.texsystem'] to an available TeX " - f"implementation.") from err - except OSError as err: - raise RuntimeError( - f"Error starting process {self.latex.args[0]!r}") from err + self._setup_latex_process(expect_reply=False) stdout, stderr = self.latex.communicate("\n\\makeatletter\\@@end\n") if self.latex.returncode != 0: raise LatexError( @@ -303,7 +294,6 @@ def __init__(self): f"while processing the following input:\n" f"{self._build_latex_header()}", stdout) - self.latex = None # Will be set up on first use. # Per-instance cache. self._get_box_metrics = functools.lru_cache()(self._get_box_metrics) @@ -318,10 +308,19 @@ def _setup_latex_process(self, *, expect_reply=True): # Windows, we must ensure that the subprocess has quit before being # able to delete the tmpdir in which it runs; in order to do so, we # must first `kill()` it, and then `communicate()` with it. - self.latex = subprocess.Popen( - [mpl.rcParams["pgf.texsystem"], "-halt-on-error"], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - encoding="utf-8", cwd=self.tmpdir) + try: + self.latex = subprocess.Popen( + [mpl.rcParams["pgf.texsystem"], "-halt-on-error"], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + encoding="utf-8", cwd=self.tmpdir) + except FileNotFoundError as err: + raise RuntimeError( + f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change " + f"rcParams['pgf.texsystem'] to an available TeX implementation" + ) from err + except OSError as err: + raise RuntimeError( + f"Error starting {mpl.rcParams['pgf.texsystem']!r}") from err def finalize_latex(latex): latex.kill() From 7bf2554609cfa3b8218394dc7fd620ddd74c7ed8 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Tue, 13 Feb 2024 20:04:17 -0700 Subject: [PATCH 3/5] Merge pull request #27785 from tacaswell/fix/windows_pgf_shutdown FIX: be careful about communicating with subprocess (cherry picked from commit c90234f5b2f3b31914860e18dce0321c83e31daf) --- lib/matplotlib/backends/backend_pgf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index d691da268460..96d60402b13e 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -307,7 +307,8 @@ def _setup_latex_process(self, *, expect_reply=True): # Open LaTeX process for real work; register it for deletion. On # Windows, we must ensure that the subprocess has quit before being # able to delete the tmpdir in which it runs; in order to do so, we - # must first `kill()` it, and then `communicate()` with it. + # must first `kill()` it, and then `communicate()` with or `wait()` on + # it. try: self.latex = subprocess.Popen( [mpl.rcParams["pgf.texsystem"], "-halt-on-error"], @@ -324,7 +325,10 @@ def _setup_latex_process(self, *, expect_reply=True): def finalize_latex(latex): latex.kill() - latex.communicate() + try: + latex.communicate() + except RuntimeError: + latex.wait() self._finalize_latex = weakref.finalize( self, finalize_latex, self.latex) From b8297e4fb7025a252bd409be83ceafa9f334911c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 14 Feb 2024 17:57:30 -0500 Subject: [PATCH 4/5] Bump pypa/cibuildwheel from 2.15.0 to 2.16.5 This is a bunch of backports joined into one, as cibuildwheel 2.16.5 fixes a bug when building on Windows. --- .github/workflows/cibuildwheel.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 6bdbb826f429..c0abc6947648 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -70,7 +70,7 @@ jobs: https://github.com/qhull/qhull/raw/2020.2/COPYING.txt - name: Build wheels for CPython 3.12 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "cp312-*" CIBW_SKIP: "*-musllinux* *i686* *win32*" @@ -94,7 +94,7 @@ jobs: pip install --pre "numpy>=1.25" - name: Build wheels for CPython 3.11 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "cp311-*" CIBW_SKIP: "*-musllinux*" @@ -107,7 +107,7 @@ jobs: CIBW_ARCHS: ${{ matrix.cibw_archs }} - name: Build wheels for CPython 3.10 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "cp310-*" CIBW_SKIP: "*-musllinux*" @@ -120,7 +120,7 @@ jobs: CIBW_ARCHS: ${{ matrix.cibw_archs }} - name: Build wheels for CPython 3.9 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "cp39-*" CIBW_SKIP: "*-musllinux*" @@ -133,7 +133,7 @@ jobs: CIBW_ARCHS: ${{ matrix.cibw_archs }} - name: Build wheels for CPython 3.8 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "cp38-*" CIBW_SKIP: "*-musllinux*" @@ -146,7 +146,7 @@ jobs: CIBW_ARCHS: ${{ matrix.cibw_archs }} - name: Build wheels for PyPy 3.8 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "pp38-*" CIBW_SKIP: "*-musllinux*" @@ -157,7 +157,7 @@ jobs: if: matrix.cibw_archs != 'aarch64' - name: Build wheels for PyPy 3.9 - uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0 + uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5 env: CIBW_BUILD: "pp39-*" CIBW_SKIP: "*-musllinux*" From e97c7f302ecef9f80d6222086a25364c3cbe911b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 16 Jan 2024 19:53:52 -0500 Subject: [PATCH 5/5] Merge pull request #27624 from ksunden/pytest8 Prepare for Pytest v8 (cherry picked from commit ed41aeaa06a64eb1c3f7344baddba410ff6a9894) Co-authored-by: Kyle Sunden --- lib/matplotlib/tests/test_colors.py | 11 ++++++++--- lib/matplotlib/tests/test_rcparams.py | 6 ++---- lib/matplotlib/tests/test_ticker.py | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 367fd6ce567f..d27771eef4d0 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1,6 +1,7 @@ import copy import itertools import unittest.mock +from packaging.version import parse as parse_version from io import BytesIO import numpy as np @@ -146,9 +147,13 @@ def test_double_register_builtin_cmap(): with pytest.raises(ValueError, match='A colormap named "viridis"'): with pytest.warns(mpl.MatplotlibDeprecationWarning): cm.register_cmap(name, mpl.colormaps[name]) - with pytest.warns(UserWarning): - # TODO is warning more than once! - cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) + + if parse_version(pytest.__version__).major < 8: + with pytest.warns(UserWarning): + cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) + else: + with pytest.warns(UserWarning), pytest.warns(mpl.MatplotlibDeprecationWarning): + cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) def test_unregister_builtin_cmap(): diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index c17e88aee1ac..9b25b9685f85 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -107,14 +107,12 @@ def test_rcparams_update(): rc = mpl.RcParams({'figure.figsize': (3.5, 42)}) bad_dict = {'figure.figsize': (3.5, 42, 1)} # make sure validation happens on input - with pytest.raises(ValueError), \ - pytest.warns(UserWarning, match="validate"): + with pytest.raises(ValueError): rc.update(bad_dict) def test_rcparams_init(): - with pytest.raises(ValueError), \ - pytest.warns(UserWarning, match="validate"): + with pytest.raises(ValueError): mpl.RcParams({'figure.figsize': (3.5, 42, 1)}) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 2bea8c999067..310efc66b67a 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -3,6 +3,7 @@ import locale import logging import re +from packaging.version import parse as parse_version import numpy as np from numpy.testing import assert_almost_equal, assert_array_equal @@ -730,10 +731,17 @@ def test_mathtext_ticks(self): 'axes.formatter.use_mathtext': False }) - with pytest.warns(UserWarning, match='cmr10 font should ideally'): - fig, ax = plt.subplots() - ax.set_xticks([-1, 0, 1]) - fig.canvas.draw() + if parse_version(pytest.__version__).major < 8: + with pytest.warns(UserWarning, match='cmr10 font should ideally'): + fig, ax = plt.subplots() + ax.set_xticks([-1, 0, 1]) + fig.canvas.draw() + else: + with pytest.warns(UserWarning, match="Glyph 8722"), \ + pytest.warns(UserWarning, match='cmr10 font should ideally'): + fig, ax = plt.subplots() + ax.set_xticks([-1, 0, 1]) + fig.canvas.draw() def test_cmr10_substitutions(self, caplog): mpl.rcParams.update({ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy