diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 634c83fa57fd..cd4c08e29fb9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -88,14 +88,31 @@ jobs: pyqt6-ver: '!=6.6.0' # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 pyside6-ver: '!=6.5.1' - - os: macos-12 # This runnre is on Intel chips. - python-version: 3.9 + - os: ubuntu-22.04 + python-version: '3.13' + # https://www.riverbankcomputing.com/pipermail/pyqt/2023-November/045606.html + pyqt6-ver: '!=6.6.0' + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 + pyside6-ver: '!=6.5.1' + - name-suffix: "Free-threaded" + os: ubuntu-22.04 + python-version: '3.13t' + # https://www.riverbankcomputing.com/pipermail/pyqt/2023-November/045606.html + pyqt6-ver: '!=6.6.0' + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 + pyside6-ver: '!=6.5.1' + - os: macos-12 # This runner is on Intel chips. + python-version: '3.9' # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 pyside6-ver: '!=6.5.1' - os: macos-14 # This runner is on M1 (arm64) chips. python-version: '3.12' # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 pyside6-ver: '!=6.5.1' + - os: macos-14 # This runner is on M1 (arm64) chips. + python-version: '3.13' + # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 + pyside6-ver: '!=6.5.1' steps: - uses: actions/checkout@v4 @@ -104,8 +121,17 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 + if: matrix.python-version != '3.13t' with: python-version: ${{ matrix.python-version }} + allow-prereleases: true + + - name: Set up Python ${{ matrix.python-version }} + uses: deadsnakes/action@6c8b9b82fe0b4344f4b98f2775fcc395df45e494 # v3.1.0 + if: matrix.python-version == '3.13t' + with: + python-version: '3.13' + nogil: true - name: Install OS dependencies run: | @@ -152,6 +178,11 @@ jobs: texlive-luatex \ texlive-pictures \ texlive-xetex + if [[ "${{ matrix.python-version }}" = '3.13t' ]]; then + # TODO: Remove this once setup-python supports nogil distributions. + sudo apt-get install -yy --no-install-recommends \ + python3.13-tk-nogil + fi if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then sudo apt-get install -yy --no-install-recommends libopengl0 else # ubuntu-22.04 @@ -202,6 +233,15 @@ jobs: 4-${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}- 4-${{ runner.os }}-py${{ matrix.python-version }}-mpl- + - name: Install the nightly dependencies + if: matrix.python-version == '3.13t' + run: | + python -m pip install pytz tzdata python-dateutil # Must be installed for Pandas. + python -m pip install \ + --pre \ + --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ + --upgrade --only-binary=:all: numpy pandas pillow contourpy + - name: Install Python dependencies run: | # Upgrade pip and setuptools and wheel to get as clean an install as @@ -227,6 +267,7 @@ jobs: # Sphinx is needed to run sphinxext tests python -m pip install --upgrade sphinx!=6.1.2 + if [[ "${{ matrix.python-version }}" != '3.13t' ]]; then # GUI toolkits are pip-installable only for some versions of Python # so don't fail if we can't install them. Make it easier to check # whether the install was successful by trying to import the toolkit @@ -246,11 +287,11 @@ jobs: python -c 'import PyQt5.QtCore' && echo 'PyQt5 is available' || echo 'PyQt5 is not available' - # Even though PySide2 wheels can be installed on Python 3.12, they are broken and since PySide2 is + # Even though PySide2 wheels can be installed on Python 3.12+, they are broken and since PySide2 is # deprecated, they are unlikely to be fixed. For the same deprecation reason, there are no wheels # on M1 macOS, so don't bother there either. if [[ "${{ matrix.os }}" != 'macos-14' - && "${{ matrix.python-version }}" != '3.12' ]]; then + && "${{ matrix.python-version }}" != '3.12' && "${{ matrix.python-version }}" != '3.13' ]]; then python -mpip install --upgrade pyside2${{ matrix.pyside2-ver }} && python -c 'import PySide2.QtCore' && echo 'PySide2 is available' || @@ -272,6 +313,8 @@ jobs: echo 'wxPython is available' || echo 'wxPython is not available' + fi # Skip backends on Python 3.13t. + - name: Install the nightly dependencies # Only install the nightly dependencies during the scheduled event if: github.event_name == 'schedule' && matrix.name-suffix != '(Minimum Versions)' @@ -310,6 +353,9 @@ jobs: - name: Run pytest run: | + if [[ "${{ matrix.python-version }}" == '3.13t' ]]; then + export PYTHON_GIL=0 + fi pytest -rfEsXR -n auto \ --maxfail=50 --timeout=300 --durations=25 \ --cov-report=xml --cov=lib --log-level=DEBUG --color=yes diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 3ec9923c0840..e99ef129eb9a 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1186,7 +1186,7 @@ def test_imshow(): @image_comparison( ['imshow_clip'], style='mpl20', - tol=1.24 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0) + tol=1.24 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0) def test_imshow_clip(): # As originally reported by Gellule Xg # use former defaults to match existing baseline image @@ -2570,7 +2570,7 @@ def test_contour_hatching(): @image_comparison( ['contour_colorbar'], style='mpl20', - tol=0.54 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0) + tol=0.54 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0) def test_contour_colorbar(): x, y, z = contour_dat() diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index d4600a14fe1c..0622c099a20c 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -442,7 +442,7 @@ def test_contourf_log_extension(split_collections): @pytest.mark.parametrize("split_collections", [False, True]) @image_comparison( ['contour_addlines.png'], remove_text=True, style='mpl20', - tol=0.15 if platform.machine() in ('aarch64', 'ppc64le', 's390x') + tol=0.15 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0.03) # tolerance is because image changed minutely when tick finding on # colorbars was cleaned up... diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index ecb51b724c27..ff5ab230ef06 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -221,7 +221,7 @@ def test_bar3d_lightsource(): @mpl3d_image_comparison( ['contour3d.png'], style='mpl20', - tol=0.002 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0) + tol=0.002 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0) def test_contour3d(): plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated fig = plt.figure()