Skip to content

ci: Enable testing on Python 3.13 #28689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ jobs:
pyqt6-ver: '!=6.6.0'
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
pyside6-ver: '!=6.5.1'
- 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.10'
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
Expand All @@ -93,6 +106,10 @@ jobs:
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
Expand All @@ -101,8 +118,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: |
Expand Down Expand Up @@ -149,6 +175,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
Expand Down Expand Up @@ -205,6 +236,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
Expand All @@ -230,6 +270,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
Expand All @@ -249,11 +290,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' ||
Expand All @@ -275,6 +316,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)'
Expand Down Expand Up @@ -313,6 +356,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
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,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 <gellule.xg@free.fr>
# use former defaults to match existing baseline image
Expand Down Expand Up @@ -2613,7 +2613,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()

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,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()
Expand Down
Loading