Skip to content

Commit

Permalink
Merge pull request #189 from lucach/main
Browse files Browse the repository at this point in the history
ci: build wheels also for linux/aarch64
  • Loading branch information
kyamagu authored Apr 27, 2023
2 parents fbca09d + aed79e1 commit cd03964
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 16 deletions.
84 changes: 69 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,91 @@ on:
types: [published]

jobs:
prebuild_linux_aarch64:
name: Build skia on linux/aarch64
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/cache@v3
id: cache-skia
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}
- name: Pre-fetch skia deps
run: git config --global core.compression 0 && cd skia && python tools/git-sync-deps
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build skia
# Taken from https://github.com/pypa/cibuildwheel/blob/v2.12.1/cibuildwheel/resources/pinned_docker_images.cfg
uses: docker://quay.io/pypa/manylinux2014_aarch64:2023-03-05-271004f
if: ${{ steps.cache-skia.outputs.cache-hit != 'true' }}
with:
args: bash -c "git config --global --add safe.directory '*' &&
bash scripts/build_Linux.sh &&
chmod a+rwx -R skia"

build_wheels:
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }})
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}) for ${{ matrix.cp }}
needs: prebuild_linux_aarch64
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
os: [ubuntu-22.04, windows-2022, macos-12]
arch: [auto64]
cp: ["cp3{7,8,9,10,11}"]
include:
# - os: ubuntu-20.04
# arch: aarch64
- os: macos-11
- os: macos-12
arch: arm64
cp: "cp3{7,8,9,10,11}"
# aarch64 is emulated and takes longer, build one wheel per job
- os: ubuntu-22.04
arch: aarch64
cp: cp37
- os: ubuntu-22.04
arch: aarch64
cp: cp38
- os: ubuntu-22.04
arch: aarch64
cp: cp39
- os: ubuntu-22.04
arch: aarch64
cp: cp310
- os: ubuntu-22.04
arch: aarch64
cp: cp311

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/cache/restore@v3
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
with:
path: |
gn
skia
key: linux-aarch64-skia-${{ github.sha }}

- name: Set up QEMU
if: runner.os == 'Linux' && matrix.arch != 'auto64'
uses: docker/setup-qemu-action@v1
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
uses: pypa/cibuildwheel@v2.12.1
env:
CIBW_BUILD: cp*
CIBW_BUILD: "${{ matrix.cp }}-*"
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_ENVIRONMENT_MACOS: TARGET_ARCH=${{ matrix.arch }}
CIBW_ENVIRONMENT_LINUX: CI_SKIP_BUILD=true
CIBW_BEFORE_ALL: bash scripts/build_${{ runner.os }}.sh
CIBW_BEFORE_BUILD: pip install pybind11 numpy
CIBW_TEST_REQUIRES: pytest pillow glfw
Expand All @@ -49,7 +103,7 @@ jobs:
xvfb-run -s "-screen 0 640x480x24" python -m pytest {project}/tests
CIBW_TEST_SKIP: "*-macosx_arm64"

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

Expand All @@ -58,14 +112,14 @@ jobs:
needs: [build_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
Expand All @@ -89,7 +143,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Binary package is available on PyPI:
pip install skia-python
```

Supported platforms:
Supported platforms: Python 3.7-3.11 (CPython) on

- Linux x86_64, aarch64
- macOS x86_64, arm64
Expand Down
5 changes: 5 additions & 0 deletions scripts/build_Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ yum install -y \
yum clean all && \
rm -rf /var/cache/yum

if [[ $(uname -m) == "aarch64" ]] && [[ $CI_SKIP_BUILD == "true" ]]; then
# gn and skia already built in a previous job
exit 0
fi

# Build gn
export CC=gcc
export CXX=g++
Expand Down

0 comments on commit cd03964

Please sign in to comment.