Skip to content

Merge pull request #3713 from damusss/remove-legacy-credits-IT #6258

Merge pull request #3713 from damusss/remove-legacy-credits-IT

Merge pull request #3713 from damusss/remove-legacy-credits-IT #6258

Workflow file for this run

name: macOS
# Run CI only when a release is created, on changes to main branch, or any PR
# to main.
on:
push:
branches: main
pull_request:
branches: main
# the github release drafter can call this workflow
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-macos
cancel-in-progress: true
jobs:
deps:
name: ${{ matrix.macarch }} deps
runs-on: ${{ matrix.os }}
strategy:
matrix:
# make arm64 deps and x86_64 deps
include:
- { macarch: arm64, os: macos-15 }
- { macarch: x86_64, os: macos-15 }
steps:
- uses: actions/checkout@v6.0.2
- name: Test for Mac Deps cache hit
id: macdep-cache
uses: actions/cache@v5.0.3
with:
path: ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }}
# The hash of all files in buildconfig manylinux-build and macdependencies is
# the key to the cache. If anything changes here, the deps are built again
key: macdep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/macdependencies/*.sh') }}-${{ matrix.macarch }}-${{ matrix.os }}
lookup-only: true
# build mac deps on cache miss
- name: Build Mac Deps
if: steps.macdep-cache.outputs.cache-hit != 'true'
run: |
export MAC_ARCH="${{ matrix.macarch }}"
brew install coreutils
cd buildconfig/macdependencies
bash ./build_mac_deps.sh
# Uncomment when you want to manually verify the deps by downloading them
# - name: Upload Mac deps
# uses: actions/upload-artifact@v6
# with:
# name: pygame-mac-deps-${{ matrix.macarch }}
# path: ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }}
build:
name: ${{ matrix.macarch }}
needs: deps
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # if a particular matrix build fails, don't skip the rest
matrix:
include:
- { macarch: arm64, os: macos-15 }
- { macarch: x86_64, os: macos-15 }
env:
MAC_ARCH: ${{ matrix.macarch }}
# We need to tell CIBW that the wheel's linking steps should be for 10.11 on x86
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macarch == 'x86_64' && '10.11' || '11.0' }}
CIBW_ARCHS: ${{ matrix.macarch }}
# Setup macOS dependencies
CIBW_BEFORE_ALL: |
cd buildconfig/macdependencies
cp -r ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }} ${{ github.workspace }}/pygame_mac_deps
bash ./install_mac_deps.sh
CIBW_BEFORE_BUILD: |
cp -r ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }} ${{ github.workspace }}/pygame_mac_deps
# To remove any speculations about the wheel not being self-contained
CIBW_BEFORE_TEST: rm -rf ${{ github.workspace }}/pygame_mac_deps
steps:
- uses: actions/checkout@v6.0.2
- name: pip cache
uses: actions/cache@v5.0.3
with:
path: ~/Library/Caches/pip # This cache path is only right on mac
key: pip-cache-${{ matrix.macarch }}-${{ matrix.os }}
- name: Fetch Mac deps
id: macdep-cache
uses: actions/cache@v5.0.3
with:
path: ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }}
key: macdep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/macdependencies/*.sh') }}-${{ matrix.macarch }}
fail-on-cache-miss: true
- name: Install uv for speed
uses: astral-sh/setup-uv@v7
with:
version: "0.9.2"
- name: Build and test wheels
uses: pypa/cibuildwheel@v3.2.1
- uses: actions/upload-artifact@v6
with:
name: macos-partial-${{ matrix.macarch }}
path: ./wheelhouse/*.whl
compression-level: 0 # wheels are already zip files, no need for more compression
universal2:
needs: build
runs-on: macos-15
steps:
- name: Download artifacts
uses: actions/download-artifact@v7
with:
merge-multiple: true
# Here we iterate over all our arm wheels, and get the corresponding intel wheel
# (matching version) and use delocate-merge to generate the final universal2
# wheel.
- name: Generate universal2 wheels
run: |
set -euo pipefail
shopt -s nullglob
pipx install delocate==0.13.0
OUT_DIR="wheelhouse"
mkdir -p "$OUT_DIR"
for arm in *arm64.whl; do
x86="$(ls "$(echo "$arm" | cut -d- -f1-4)"-macosx_*_x86_64.whl 2>/dev/null | head -n1 || true)"
if [[ ! -f "$x86" ]]; then
echo "Copying arm wheel as is (missing x86 component): $arm"
mv "$arm" "$OUT_DIR"
continue
fi
echo "Merging:"
echo " ARM: $arm"
echo " X86: $x86"
delocate-merge "$arm" "$x86" -w "$OUT_DIR"
rm "$x86"
done
for x86 in *x86_64.whl; do
echo "Copying x86_64 wheel as is (missing arm component): $x86"
mv "$x86" "$OUT_DIR"
done
- name: Sanity check - install and test a single universal2 wheel
env:
# Pip now forces us to either make a venv or set this flag, so we will do
# this
PIP_BREAK_SYSTEM_PACKAGES: 1
SDL_VIDEODRIVER: "dummy"
SDL_AUDIODRIVER: "disk"
run: |
python3 -m pip install --no-index --find-links wheelhouse pygame-ce
python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300
- uses: actions/upload-artifact@v6
with:
name: pygame-wheels-macos
path: ./wheelhouse/*.whl
compression-level: 0 # wheels are already zip files, no need for more compression