Skip to content

Commit 97c1282

Browse files
authored
Merge pull request matplotlib#27723 from QuLogic/macos-m1
ci: Enable testing on M1 macOS
2 parents 4b42dbb + 48bc62d commit 97c1282

31 files changed

+302
-216
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ jobs:
116116
CIBW_SKIP: "*-musllinux_aarch64"
117117
CIBW_TEST_COMMAND: >-
118118
python {package}/ci/check_version_number.py
119-
# Apple Silicon machines are not available for testing, so silence the
120-
# warning from cibuildwheel. Remove the skip when they're available.
121-
CIBW_TEST_SKIP: "*-macosx_arm64"
122-
MACOSX_DEPLOYMENT_TARGET: "10.12"
123119
MPL_DISABLE_FH4: "yes"
124120
strategy:
125121
matrix:
@@ -131,7 +127,15 @@ jobs:
131127
- os: windows-latest
132128
cibw_archs: "auto64"
133129
- os: macos-11
134-
cibw_archs: "x86_64 arm64"
130+
cibw_archs: "x86_64"
131+
# NOTE: macos_target can be moved back into global environment after
132+
# meson-python 0.16.0 is released.
133+
macos_target: "10.12"
134+
- os: macos-14
135+
cibw_archs: "arm64"
136+
# NOTE: macos_target can be moved back into global environment after
137+
# meson-python 0.16.0 is released.
138+
macos_target: "11.0"
135139

136140
steps:
137141
- name: Set up QEMU
@@ -153,6 +157,7 @@ jobs:
153157
env:
154158
CIBW_BUILD: "cp312-*"
155159
CIBW_ARCHS: ${{ matrix.cibw_archs }}
160+
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
156161

157162
- name: Build wheels for CPython 3.11
158163
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
@@ -161,6 +166,7 @@ jobs:
161166
env:
162167
CIBW_BUILD: "cp311-*"
163168
CIBW_ARCHS: ${{ matrix.cibw_archs }}
169+
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
164170

165171
- name: Build wheels for CPython 3.10
166172
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
@@ -169,6 +175,7 @@ jobs:
169175
env:
170176
CIBW_BUILD: "cp310-*"
171177
CIBW_ARCHS: ${{ matrix.cibw_archs }}
178+
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
172179

173180
- name: Build wheels for CPython 3.9
174181
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
@@ -177,6 +184,7 @@ jobs:
177184
env:
178185
CIBW_BUILD: "cp39-*"
179186
CIBW_ARCHS: ${{ matrix.cibw_archs }}
187+
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
180188

181189
- name: Build wheels for PyPy
182190
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
@@ -185,6 +193,7 @@ jobs:
185193
env:
186194
CIBW_BUILD: "pp39-*"
187195
CIBW_ARCHS: ${{ matrix.cibw_archs }}
196+
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
188197
if: matrix.cibw_archs != 'aarch64'
189198

190199
- uses: actions/upload-artifact@v4

.github/workflows/tests.yml

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ jobs:
8787
pyqt6-ver: '!=6.6.0'
8888
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
8989
pyside6-ver: '!=6.5.1'
90-
- os: macos-latest
90+
- os: macos-12 # This runnre is on Intel chips.
9191
python-version: 3.9
9292
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
9393
pyside6-ver: '!=6.5.1'
94+
- os: macos-14 # This runner is on M1 (arm64) chips.
95+
python-version: '3.12'
96+
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
97+
pyside6-ver: '!=6.5.1'
9498

9599
steps:
96100
- uses: actions/checkout@v4
@@ -157,7 +161,8 @@ jobs:
157161
macOS)
158162
brew install ccache
159163
brew tap homebrew/cask-fonts
160-
brew install font-noto-sans-cjk gobject-introspection gtk4 ninja
164+
brew install font-noto-sans-cjk ghostscript gobject-introspection gtk4 ninja
165+
brew install --cask inkscape
161166
;;
162167
esac
163168
@@ -228,7 +233,6 @@ jobs:
228233
# (sometimes, the install appears to be successful but shared
229234
# libraries cannot be loaded at runtime, so an actual import is a
230235
# better check).
231-
# PyGObject, pycairo, and cariocffi do not install on macOS 10.12.
232236
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
233237
(
234238
python -c 'import gi; gi.require_version("Gtk", "4.0"); from gi.repository import Gtk' &&
@@ -238,43 +242,35 @@ jobs:
238242
echo 'PyGObject 3 is available' || echo 'PyGObject 3 is not available'
239243
)
240244
241-
# There are no functioning wheels available for macOS 10.12 (as of
242-
# Sept 2020) for either pyqt5 (there are only wheels for 10.13+) or
243-
# pyside2 (the latest version (5.13.2) with 10.12 wheels has a
244-
# fatal to us bug, it was fixed in 5.14.0 which has 10.13 wheels)
245245
python -mpip install --upgrade pyqt5${{ matrix.pyqt5-ver }} &&
246246
python -c 'import PyQt5.QtCore' &&
247247
echo 'PyQt5 is available' ||
248248
echo 'PyQt5 is not available'
249-
if [[ "${{ runner.os }}" != 'macOS'
249+
# Even though PySide2 wheels can be installed on Python 3.12, they are broken and since PySide2 is
250+
# deprecated, they are unlikely to be fixed. For the same deprecation reason, there are no wheels
251+
# on M1 macOS, so don't bother there either.
252+
if [[ "${{ matrix.os }}" != 'macos-14'
250253
&& "${{ matrix.python-version }}" != '3.12' ]]; then
251254
python -mpip install --upgrade pyside2${{ matrix.pyside2-ver }} &&
252255
python -c 'import PySide2.QtCore' &&
253256
echo 'PySide2 is available' ||
254257
echo 'PySide2 is not available'
255258
fi
256-
if [[ "${{ runner.os }}" != 'macOS' ]]; then
257-
python -mpip install --upgrade pyqt6${{ matrix.pyqt6-ver }} &&
258-
python -c 'import PyQt6.QtCore' &&
259-
echo 'PyQt6 is available' ||
260-
echo 'PyQt6 is not available'
261-
fi
262-
if [[ "${{ runner.os }}" != 'macOS'
263-
&& "${{ matrix.python-version }}" != '3.12' ]]; then
264-
python -mpip install --upgrade pyside6${{ matrix.pyside6-ver }} &&
265-
python -c 'import PySide6.QtCore' &&
266-
echo 'PySide6 is available' ||
267-
echo 'PySide6 is not available'
268-
fi
259+
python -mpip install --upgrade pyqt6${{ matrix.pyqt6-ver }} &&
260+
python -c 'import PyQt6.QtCore' &&
261+
echo 'PyQt6 is available' ||
262+
echo 'PyQt6 is not available'
263+
python -mpip install --upgrade pyside6${{ matrix.pyside6-ver }} &&
264+
python -c 'import PySide6.QtCore' &&
265+
echo 'PySide6 is available' ||
266+
echo 'PySide6 is not available'
269267
270-
if [[ "${{ matrix.python-version }}" != '3.12' ]]; then
271-
python -mpip install --upgrade \
272-
-f "https://extras.wxpython.org/wxPython4/extras/linux/gtk3/${{ matrix.os }}" \
273-
wxPython &&
274-
python -c 'import wx' &&
275-
echo 'wxPython is available' ||
276-
echo 'wxPython is not available'
277-
fi
268+
python -mpip install --upgrade \
269+
-f "https://extras.wxpython.org/wxPython4/extras/linux/gtk3/${{ matrix.os }}" \
270+
wxPython &&
271+
python -c 'import wx' &&
272+
echo 'wxPython is available' ||
273+
echo 'wxPython is not available'
278274
279275
- name: Install the nightly dependencies
280276
# Only install the nightly dependencies during the scheduled event

lib/matplotlib/backends/backend_svg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,11 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10851085
writer.end('g')
10861086

10871087
def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
1088+
# NOTE: If you change the font styling CSS, then be sure the check for
1089+
# svg.fonttype = none in `lib/matplotlib/testing/compare.py::convert` remains in
1090+
# sync. Also be sure to re-generate any SVG using this mode, or else such tests
1091+
# will fail to use the right converter for the expected images, and they will
1092+
# fail strangely.
10881093
writer = self.writer
10891094

10901095
color = rgb2hex(gc.get_rgb())

lib/matplotlib/testing/compare.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ def convert(filename, cache):
300300
convert = converter[path.suffix[1:]]
301301
if path.suffix == ".svg":
302302
contents = path.read_text()
303+
# NOTE: This check should be kept in sync with font styling in
304+
# `lib/matplotlib/backends/backend_svg.py`. If it changes, then be sure to
305+
# re-generate any SVG test files using this mode, or else such tests will
306+
# fail to use the converter for the expected images (but will for the
307+
# results), and the tests will fail strangely.
303308
if 'style="font:' in contents:
304309
# for svg.fonttype = none, we explicitly patch the font search
305310
# path so that fonts shipped by Matplotlib are found.

0 commit comments

Comments
 (0)