Skip to content

Commit 55c38af

Browse files
authored
Merge pull request matplotlib#28926 from QuLogic/auto-backport-of-pr-28689-on-v3.9.x
Backport PR matplotlib#28689 on branch v3.9.x (ci: Enable testing on Python 3.13)
2 parents 956b134 + ab09fcc commit 55c38af

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

.github/workflows/tests.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,31 @@ jobs:
8888
pyqt6-ver: '!=6.6.0'
8989
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
9090
pyside6-ver: '!=6.5.1'
91-
- os: macos-12 # This runnre is on Intel chips.
92-
python-version: 3.9
91+
- os: ubuntu-22.04
92+
python-version: '3.13'
93+
# https://www.riverbankcomputing.com/pipermail/pyqt/2023-November/045606.html
94+
pyqt6-ver: '!=6.6.0'
95+
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
96+
pyside6-ver: '!=6.5.1'
97+
- name-suffix: "Free-threaded"
98+
os: ubuntu-22.04
99+
python-version: '3.13t'
100+
# https://www.riverbankcomputing.com/pipermail/pyqt/2023-November/045606.html
101+
pyqt6-ver: '!=6.6.0'
102+
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
103+
pyside6-ver: '!=6.5.1'
104+
- os: macos-12 # This runner is on Intel chips.
105+
python-version: '3.9'
93106
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
94107
pyside6-ver: '!=6.5.1'
95108
- os: macos-14 # This runner is on M1 (arm64) chips.
96109
python-version: '3.12'
97110
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
98111
pyside6-ver: '!=6.5.1'
112+
- os: macos-14 # This runner is on M1 (arm64) chips.
113+
python-version: '3.13'
114+
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
115+
pyside6-ver: '!=6.5.1'
99116

100117
steps:
101118
- uses: actions/checkout@v4
@@ -104,8 +121,17 @@ jobs:
104121

105122
- name: Set up Python ${{ matrix.python-version }}
106123
uses: actions/setup-python@v5
124+
if: matrix.python-version != '3.13t'
107125
with:
108126
python-version: ${{ matrix.python-version }}
127+
allow-prereleases: true
128+
129+
- name: Set up Python ${{ matrix.python-version }}
130+
uses: deadsnakes/action@6c8b9b82fe0b4344f4b98f2775fcc395df45e494 # v3.1.0
131+
if: matrix.python-version == '3.13t'
132+
with:
133+
python-version: '3.13'
134+
nogil: true
109135

110136
- name: Install OS dependencies
111137
run: |
@@ -152,6 +178,11 @@ jobs:
152178
texlive-luatex \
153179
texlive-pictures \
154180
texlive-xetex
181+
if [[ "${{ matrix.python-version }}" = '3.13t' ]]; then
182+
# TODO: Remove this once setup-python supports nogil distributions.
183+
sudo apt-get install -yy --no-install-recommends \
184+
python3.13-tk-nogil
185+
fi
155186
if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then
156187
sudo apt-get install -yy --no-install-recommends libopengl0
157188
else # ubuntu-22.04
@@ -202,6 +233,15 @@ jobs:
202233
4-${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}-
203234
4-${{ runner.os }}-py${{ matrix.python-version }}-mpl-
204235
236+
- name: Install the nightly dependencies
237+
if: matrix.python-version == '3.13t'
238+
run: |
239+
python -m pip install pytz tzdata python-dateutil # Must be installed for Pandas.
240+
python -m pip install \
241+
--pre \
242+
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
243+
--upgrade --only-binary=:all: numpy pandas pillow contourpy
244+
205245
- name: Install Python dependencies
206246
run: |
207247
# Upgrade pip and setuptools and wheel to get as clean an install as
@@ -227,6 +267,7 @@ jobs:
227267
# Sphinx is needed to run sphinxext tests
228268
python -m pip install --upgrade sphinx!=6.1.2
229269
270+
if [[ "${{ matrix.python-version }}" != '3.13t' ]]; then
230271
# GUI toolkits are pip-installable only for some versions of Python
231272
# so don't fail if we can't install them. Make it easier to check
232273
# whether the install was successful by trying to import the toolkit
@@ -246,11 +287,11 @@ jobs:
246287
python -c 'import PyQt5.QtCore' &&
247288
echo 'PyQt5 is available' ||
248289
echo 'PyQt5 is not available'
249-
# Even though PySide2 wheels can be installed on Python 3.12, they are broken and since PySide2 is
290+
# Even though PySide2 wheels can be installed on Python 3.12+, they are broken and since PySide2 is
250291
# deprecated, they are unlikely to be fixed. For the same deprecation reason, there are no wheels
251292
# on M1 macOS, so don't bother there either.
252293
if [[ "${{ matrix.os }}" != 'macos-14'
253-
&& "${{ matrix.python-version }}" != '3.12' ]]; then
294+
&& "${{ matrix.python-version }}" != '3.12' && "${{ matrix.python-version }}" != '3.13' ]]; then
254295
python -mpip install --upgrade pyside2${{ matrix.pyside2-ver }} &&
255296
python -c 'import PySide2.QtCore' &&
256297
echo 'PySide2 is available' ||
@@ -272,6 +313,8 @@ jobs:
272313
echo 'wxPython is available' ||
273314
echo 'wxPython is not available'
274315
316+
fi # Skip backends on Python 3.13t.
317+
275318
- name: Install the nightly dependencies
276319
# Only install the nightly dependencies during the scheduled event
277320
if: github.event_name == 'schedule' && matrix.name-suffix != '(Minimum Versions)'
@@ -310,6 +353,9 @@ jobs:
310353

311354
- name: Run pytest
312355
run: |
356+
if [[ "${{ matrix.python-version }}" == '3.13t' ]]; then
357+
export PYTHON_GIL=0
358+
fi
313359
pytest -rfEsXR -n auto \
314360
--maxfail=50 --timeout=300 --durations=25 \
315361
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def test_imshow():
11861186

11871187
@image_comparison(
11881188
['imshow_clip'], style='mpl20',
1189-
tol=1.24 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0)
1189+
tol=1.24 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0)
11901190
def test_imshow_clip():
11911191
# As originally reported by Gellule Xg <gellule.xg@free.fr>
11921192
# use former defaults to match existing baseline image
@@ -2570,7 +2570,7 @@ def test_contour_hatching():
25702570

25712571
@image_comparison(
25722572
['contour_colorbar'], style='mpl20',
2573-
tol=0.54 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0)
2573+
tol=0.54 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0)
25742574
def test_contour_colorbar():
25752575
x, y, z = contour_dat()
25762576

lib/matplotlib/tests/test_contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def test_contourf_log_extension(split_collections):
442442
@pytest.mark.parametrize("split_collections", [False, True])
443443
@image_comparison(
444444
['contour_addlines.png'], remove_text=True, style='mpl20',
445-
tol=0.15 if platform.machine() in ('aarch64', 'ppc64le', 's390x')
445+
tol=0.15 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x')
446446
else 0.03)
447447
# tolerance is because image changed minutely when tick finding on
448448
# colorbars was cleaned up...

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_bar3d_lightsource():
221221

222222
@mpl3d_image_comparison(
223223
['contour3d.png'], style='mpl20',
224-
tol=0.002 if platform.machine() in ('aarch64', 'ppc64le', 's390x') else 0)
224+
tol=0.002 if platform.machine() in ('aarch64', 'arm64', 'ppc64le', 's390x') else 0)
225225
def test_contour3d():
226226
plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated
227227
fig = plt.figure()

0 commit comments

Comments
 (0)