Skip to content

Commit

Permalink
Merge pull request #147 from googlefonts/cibuildwheel
Browse files Browse the repository at this point in the history
replace multibuild with cibuildwheel, build 3.10, universal2, aarch wheels
  • Loading branch information
anthrotype committed Dec 1, 2021
2 parents de5929e + 2a00956 commit f567292
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 135 deletions.
196 changes: 96 additions & 100 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,132 +8,134 @@ on:
branches: [main]

env:
PROJECT_NAME: "compreffor"
TEST_DEPENDS: "tox"
CIBW_TEST_REQUIRES: "pytest -rrequirements.txt"
CIBW_TEST_COMMAND: "pytest --pyargs compreffor"

jobs:
build_unix:

build_sdist:
name: Build Source Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
# setuptools_scm won't work with shallow clone; fetch all history
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Build sdist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*.tar.gz
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

build_wheels:
name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest]
platform: [x64]
env:
REPO_DIR: "."
PLAT: "x86_64"
UNICODE_WIDTH: 32
MB_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
os: [macos-latest, windows-latest]
arch: [auto64]
build: ["*"]
skip: ["cp36-* pp*"]
include:
# the manylinux1 docker images only contain from python3.7 to 3.9
- os: ubuntu-latest
type: manylinux1
arch: auto64
build: "cp{37,38,39}-manylinux*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
CIBW_MANYLINUX_I686_IMAGE: manylinux1
# the manylinux2010 image also contains python 3.10
- os: ubuntu-latest
arch: auto64
type: manylinux2010
build: "pp*-manylinux* cp310-manylinux*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010
CIBW_MANYLINUX_I686_IMAGE: manylinux2010

- os: macos-latest
arch: universal2
build: "*"
skip: "cp36-* pp*"

- os: windows-latest
arch: auto32
build: "*"
skip: "cp36-* pp*"
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform }}
- name: Set up environment variables
run: |
if [ "macos-latest" == "${{ matrix.os }}" ]; then
echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV
else
echo "TRAVIS_OS_NAME=ubuntu" >> $GITHUB_ENV
fi
- name: Install virtualenv
run: |
python -m pip install --upgrade pip
pip install virtualenv
- name: Build and Install Wheels
run: |
source multibuild/common_utils.sh
source multibuild/travis_steps.sh
echo "------- BEFORE INSTALL --------"
before_install
echo "------- BUILD WHEEL --------"
build_wheel $REPO_DIR $PLAT
echo "------- INSTALL_RUN --------"
install_run $PLAT
python-version: "3.x"
- name: Install dependencies
run: pip install cibuildwheel
- name: Build Wheels
run: python -m cibuildwheel --output-dir wheelhouse .
env:
CIBW_BUILD: ${{ matrix.build }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.CIBW_MANYLINUX_I686_IMAGE }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.CIBW_MANYLINUX_X86_64_IMAGE }}
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: ${{ matrix.skip }}
- uses: actions/upload-artifact@v2
with:
name: ${{ env.PROJECT_NAME }}-py${{ matrix.python-version }}-${{ env.TRAVIS_OS_NAME }}-${{ matrix.platform }}
path: wheelhouse/*.whl

build_win:
runs-on: windows-latest
build_arch_wheels:
name: py${{ matrix.python }} on ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
platform: [x64, x86]
# aarch64 uses qemu so it's slow, build each py version in parallel jobs
python: [37, 38, 39, 310]
arch: [aarch64]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
fetch-depth: 0
- uses: docker/setup-qemu-action@v1.2.0
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform }}
- name: Set up virtual environment
run: |
python -m pip install --upgrade virtualenv
python -m virtualenv venv
venv\Scripts\activate
python -c "import sys; print(sys.version); print(sys.executable)"
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install ${{ env.TEST_DEPENDS }}
- name: Build wheel
run: |
venv\Scripts\activate
pip wheel --no-deps -w wheelhouse .
- name: Run the tests
run: |
venv\Scripts\activate
Get-ChildItem wheelhouse\${{ env.PROJECT_NAME }}*.whl -OutVariable WHEEL_PATH
tox --installpkg $WHEEL_PATH -e py
platforms: all
- name: Install dependencies
run: pip install cibuildwheel
- name: Build Wheels
run: python -m cibuildwheel --output-dir wheelhouse .
env:
CIBW_BUILD: cp${{ matrix.python }}-manylinux*
CIBW_ARCHS: ${{ matrix.arch }}
- uses: actions/upload-artifact@v2
with:
name: ${{ env.PROJECT_NAME }}-py${{ matrix.python-version }}-win-${{ matrix.platform }}
path: wheelhouse/*.whl

deploy:
# only run if the commit is tagged...
name: Upload if tagged commit
if: startsWith(github.ref, 'refs/tags/')
# ... and all build jobs completed successfully
needs:
- build_unix
- build_win
# but only if all build jobs completed successfully
needs: [build_wheels, build_arch_wheels, build_sdist]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/download-artifact@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
- name: Download artifacts from build jobs
uses: actions/download-artifact@v2
with:
path: wheelhouse/
- name: Move wheels to dist/ directory
run: |
ls wheelhouse/*
mkdir -p dist/
for wheel_dir in wheelhouse/${{ env.PROJECT_NAME }}*/; do
mv "${wheel_dir}"/*.whl dist/
done
name: artifact
path: dist

- name: Extract release notes from annotated tag message
id: release_notes
env:
Expand All @@ -156,6 +158,7 @@ jobs:
echo "Tag does not contain pre-release suffix"
echo "IS_PRERELEASE=false" >> "$GITHUB_ENV"
fi
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
Expand All @@ -168,15 +171,8 @@ jobs:
body_path: "${{ runner.temp }}/release_notes.md"
draft: false
prerelease: ${{ env.IS_PRERELEASE }}
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
if [ "$IS_PRERELEASE" == true ]; then
echo "DEBUG: This is a pre-release"
else
echo "DEBUG: This is a final release"
fi
python setup.py sdist
twine upload dist/*

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "cxx-src/mingw-std-threads"]
path = src/cxx/mingw-std-threads
url = https://github.com/meganz/mingw-std-threads
[submodule "multibuild"]
path = multibuild
url = https://github.com/matthew-brett/multibuild
26 changes: 0 additions & 26 deletions config.sh

This file was deleted.

1 change: 0 additions & 1 deletion multibuild
Submodule multibuild deleted from 938d95
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fonttools==4.2.0
fonttools==4.28.2
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[tox]
envlist = py{36,37}
envlist = py3{7,8,9,10}

[testenv]
deps =
pytest
-rrequirements.txt
commands =
# run the test suite against installed package; pass extra args to pytest
py.test --pyargs compreffor {posargs}
# if toxenv contains 'wheels' tag, also build the wheel packages
wheels: pip wheel -w {distdir} --no-deps .
pytest --pyargs compreffor {posargs}

0 comments on commit f567292

Please sign in to comment.