Skip to content

Commit b3aaff3

Browse files
authored
Merge pull request #3625 from pygame-community/ankith26-mac-universal2
Make universal2 wheels on macos
2 parents f80f75f + aa137b9 commit b3aaff3

File tree

2 files changed

+59
-10
lines changed

2 files changed

+59
-10
lines changed

.github/workflows/build-macos.yml

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ jobs:
7070
env:
7171
MAC_ARCH: ${{ matrix.macarch }}
7272

73-
# Explicitly tell CIBW what the wheel arch deployment target should be
74-
# There seems to be no better way to set this than this env
75-
# We need this because our minimum is 10.11, different from default
76-
# of 10.9 on x86s
77-
# Related issue: https://github.com/pypa/cibuildwheel/issues/952
78-
_PYTHON_HOST_PLATFORM: ${{ matrix.macarch == 'x86_64' && 'macosx-10.11-x86_64' || 'macosx-11.0-arm64'}}
79-
80-
# Similarly, we need to tell CIBW that the wheel's linking steps
81-
# should be for 10.11 on x86
73+
# We need to tell CIBW that the wheel's linking steps should be for 10.11 on x86
8274
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macarch == 'x86_64' && '10.11' || '11.0' }}
8375

8476
CIBW_ARCHS: ${{ matrix.macarch }}
@@ -122,6 +114,62 @@ jobs:
122114

123115
- uses: actions/upload-artifact@v6
124116
with:
125-
name: pygame-wheels-macos-${{ matrix.macarch }}
117+
name: macos-partial-${{ matrix.macarch }}
118+
path: ./wheelhouse/*.whl
119+
compression-level: 0 # wheels are already zip files, no need for more compression
120+
121+
universal2:
122+
needs: build
123+
runs-on: macos-15
124+
steps:
125+
- name: Download artifacts
126+
uses: actions/download-artifact@v7
127+
with:
128+
merge-multiple: true
129+
130+
# Here we iterate over all our arm wheels, and get the corresponding intel wheel
131+
# (matching version) and use delocate-merge to generate the final universal2
132+
# wheel.
133+
- name: Generate universal2 wheels
134+
run: |
135+
set -euo pipefail
136+
shopt -s nullglob
137+
138+
pipx install delocate==0.13.0
139+
140+
OUT_DIR="wheelhouse"
141+
mkdir -p "$OUT_DIR"
142+
for arm in *arm64.whl; do
143+
x86="$(ls "$(echo "$arm" | cut -d- -f1-4)"-macosx_*_x86_64.whl 2>/dev/null | head -n1 || true)"
144+
if [[ ! -f "$x86" ]]; then
145+
echo "Copying arm wheel as is (missing x86 component): $arm"
146+
mv "$arm" "$OUT_DIR"
147+
continue
148+
fi
149+
echo "Merging:"
150+
echo " ARM: $arm"
151+
echo " X86: $x86"
152+
delocate-merge "$arm" "$x86" -w "$OUT_DIR"
153+
rm "$x86"
154+
done
155+
for x86 in *x86_64.whl; do
156+
echo "Copying x86_64 wheel as is (missing arm component): $x86"
157+
mv "$x86" "$OUT_DIR"
158+
done
159+
160+
- name: Sanity check - install and test a single universal2 wheel
161+
env:
162+
# Pip now forces us to either make a venv or set this flag, so we will do
163+
# this
164+
PIP_BREAK_SYSTEM_PACKAGES: 1
165+
SDL_VIDEODRIVER: "dummy"
166+
SDL_AUDIODRIVER: "disk"
167+
run: |
168+
python3 -m pip install --no-index --find-links wheelhouse pygame-ce
169+
python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300
170+
171+
- uses: actions/upload-artifact@v6
172+
with:
173+
name: pygame-wheels-macos
126174
path: ./wheelhouse/*.whl
127175
compression-level: 0 # wheels are already zip files, no need for more compression

.github/workflows/release-gh-draft.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
uses: actions/download-artifact@v7
3333
with:
3434
path: pygame-wheels
35+
pattern: pygame-wheels-*
3536
merge-multiple: true
3637

3738
# Strips 'release/' from the ref_name, this helps us access the version

0 commit comments

Comments
 (0)