Skip to content

Commit 65e06eb

Browse files
authored
Merge pull request #50 from fonttools/mac-m1-arm64
Support building mac universal2 wheels
2 parents 46c6c2f + 677314f commit 65e06eb

File tree

8 files changed

+111
-216
lines changed

8 files changed

+111
-216
lines changed

.github/workflows/ci.yml

+29-42
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,36 @@ on:
77
pull_request:
88
branches: [master]
99

10+
env:
11+
# skip 3.6 on all platforms; only build pypy3 for linux
12+
CIBW_SKIP: cp36-* pp*-macosx_x86_64 pp*-win_amd64
13+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
14+
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
15+
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux2014
16+
CIBW_TEST_EXTRAS: testing
17+
CIBW_TEST_COMMAND: pytest {project}/tests
18+
BUILD_SKIA_FROM_SOURCE: 0
19+
SKIA_LIBRARY_DIR: "build/download"
20+
CIBW_ENVIRONMENT: BUILD_SKIA_FROM_SOURCE=0 SKIA_LIBRARY_DIR=build/download
21+
1022
jobs:
1123
build:
12-
1324
runs-on: ${{ matrix.os }}
25+
env:
26+
CIBW_ARCHS: ${{ matrix.arch }}
1427
defaults:
1528
run:
1629
shell: bash
1730
strategy:
1831
fail-fast: false
1932
matrix:
20-
python-version: [3.6, 3.7, 3.8, 3.9, "pypy3.7-7.3.5"]
21-
os: [ubuntu-latest, macos-latest]
22-
platform: [x64]
23-
exclude:
33+
os: [macos-latest, ubuntu-latest, windows-latest]
34+
arch: [auto64]
35+
include:
2436
- os: macos-latest
25-
python-version: "pypy3.7-7.3.5"
26-
env:
27-
REPO_DIR: "."
28-
PLAT: "x86_64"
29-
UNICODE_WIDTH: 32
30-
MB_PYTHON_VERSION: "${{ matrix.python-version }}"
31-
MB_ML_VER: 2014
32-
DOCKER_TEST_IMAGE: "multibuild/xenial_x86_64"
33-
TEST_DEPENDS: "tox"
34-
BUILD_SKIA_FROM_SOURCE: 0
35-
SKIA_LIBRARY_DIR: "build/download"
36-
37+
arch: universal2
38+
- os: windows-latest
39+
arch: x86
3740
steps:
3841
- uses: actions/checkout@v2
3942
with:
@@ -42,40 +45,24 @@ jobs:
4245
uses: actions/setup-python@v2
4346
with:
4447
python-version: "3.x"
45-
- name: Set up environment variables
46-
run: |
47-
if [ "macos-latest" == "${{ matrix.os }}" ]; then
48-
echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV
49-
else
50-
echo "TRAVIS_OS_NAME=ubuntu" >> $GITHUB_ENV
51-
fi
52-
echo "export BUILD_SKIA_FROM_SOURCE=${BUILD_SKIA_FROM_SOURCE}" >> env_vars.sh
53-
echo "export SKIA_LIBRARY_DIR=${SKIA_LIBRARY_DIR}" >> env_vars.sh
54-
- name: Install virtualenv
55-
run: |
56-
python -m pip install --upgrade pip
57-
pip install virtualenv
5848
- name: Download pre-compiled libskia
5949
env:
6050
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
6151
run: |
6252
if [ "$BUILD_SKIA_FROM_SOURCE" == "0" ]; then
6353
pip install githubrelease
64-
python ci/download_libskia.py -d "${SKIA_LIBRARY_DIR}"
54+
if ! [[ $CIBW_ARCHS =~ ^auto ]]; then
55+
cpu_arch="--cpu-arch=$CIBW_ARCHS"
56+
fi
57+
python ci/download_libskia.py -d "${SKIA_LIBRARY_DIR}" $cpu_arch
6558
fi
66-
- name: Build and Install Wheels
67-
run: |
68-
source multibuild/common_utils.sh
69-
source multibuild/travis_steps.sh
70-
echo "------- BEFORE INSTALL --------"
71-
before_install
72-
echo "------- BUILD WHEEL --------"
73-
build_wheel $REPO_DIR $PLAT
74-
echo "------- INSTALL_RUN --------"
75-
install_run $PLAT
59+
- name: Install dependencies
60+
run: pip install cibuildwheel
61+
- name: Build and Test Wheels
62+
run: python -m cibuildwheel --output-dir wheelhouse
7663
- uses: actions/upload-artifact@v2
7764
with:
78-
name: skia_pathops-${{ env.TRAVIS_OS_NAME }}-${{ matrix.python-version }}
65+
name: skia_pathops-${{ matrix.os }}-${{ matrix.arch }}
7966
path: wheelhouse/*.whl
8067

8168
deploy:

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "multibuild"]
2-
path = multibuild
3-
url = https://github.com/matthew-brett/multibuild/
41
[submodule "src/cpp/skia-builder"]
52
path = src/cpp/skia-builder
63
url = https://github.com/fonttools/skia-builder

appveyor.yml

-94
This file was deleted.

ci/download_libskia.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import struct
88
import tempfile
9+
from distutils.util import get_platform
910

1011
__requires__ = ["github_release"]
1112

@@ -15,8 +16,18 @@
1516
GITHUB_REPO = "fonttools/skia-builder"
1617
ASSET_TEMPLATE = "libskia-{plat}-{arch}.zip"
1718
DOWNLOAD_DIR = os.path.join("build", "download")
18-
CPU_ARCH = "x64" if struct.calcsize("P") * 8 == 64 else "x86"
19+
1920
PLATFORM_TAGS = {"Linux": "linux", "Darwin": "mac", "Windows": "win"}
21+
CURRENT_PLATFORM = PLATFORM_TAGS.get(platform.system())
22+
SUPPORTED_CPU_ARCHS = {
23+
"linux": {"x64"},
24+
"mac": {"x64", "arm64", "universal2"},
25+
"win": {"x64", "x86"},
26+
}
27+
machine = get_platform().split("-")[-1]
28+
CURRENT_CPU_ARCH = {"win32": "x86", "amd64": "x64", "x86_64": "x64"}.get(
29+
machine, machine
30+
)
2031

2132

2233
logger = logging.getLogger()
@@ -57,16 +68,16 @@ def download_unpack_assets(repo, tag, asset_name, dest_dir):
5768
parser.add_argument(
5869
"-p",
5970
"--platform",
60-
default=PLATFORM_TAGS.get(platform.system(), "win"),
71+
default=CURRENT_PLATFORM,
6172
choices=["win", "mac", "linux"],
6273
help="The desired platform (default: %(default)s)",
6374
)
6475
parser.add_argument(
6576
"-a",
6677
"--cpu-arch",
67-
default=CPU_ARCH,
78+
default=CURRENT_CPU_ARCH,
6879
help="The desired CPU architecture (default: %(default)s)",
69-
choices=["x86", "x64"],
80+
choices=["x86", "x64", "arm64", "universal2"],
7081
)
7182
parser.add_argument(
7283
"-d",
@@ -79,6 +90,11 @@ def download_unpack_assets(repo, tag, asset_name, dest_dir):
7990
)
8091
args = parser.parse_args()
8192

93+
if args.platform is None:
94+
parser.error(f"Unsupported platform: {platform.system()}")
95+
if args.cpu_arch not in SUPPORTED_CPU_ARCHS[args.platform]:
96+
parser.error(f"Unsupported architecture for {args.platform}: {args.cpu_arch}")
97+
8298
tag_name = args.tag_name
8399
if tag_name is None:
84100
latest_release = get_latest_release(GITHUB_REPO)

config.sh

-28
This file was deleted.

multibuild

-1
This file was deleted.

0 commit comments

Comments
 (0)