Skip to content

Commit

Permalink
Merge pull request #44 from fonttools/cibuildwheel
Browse files Browse the repository at this point in the history
use cibuildwheel instead of multibuild to build wheels
  • Loading branch information
anthrotype authored Dec 1, 2021
2 parents 0bfbf85 + 6e73da8 commit 2ec1236
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 132 deletions.
205 changes: 97 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,141 +2,136 @@ name: Build + Deploy

on:
push:
branches: [master]
branches: [main]
tags: ["*.*.*"]
pull_request:
branches: [master]
branches: [main]

env:
PROJECT_NAME: "pyclipper"
BUILD_DEPENDS: "Cython setuptools>=25 setuptools_scm setuptools_scm_git_archive"
TEST_DEPENDS: "sympy unittest2 pytest"
CIBW_TEST_REQUIRES: "sympy pytest"
CIBW_TEST_COMMAND: pytest {package}/tests -v

jobs:
build_unix:

build_sdist:
name: Build Source Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# 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: ["pp*"]
include:
# the manylinux1 docker images only contain from python3.6 to 3.9
- os: ubuntu-latest
type: manylinux1
arch: auto64
build: "cp{36,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: "pp*"

- os: windows-latest
arch: auto32
build: "*"
skip: "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: [36, 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.BUILD_DEPENDS }}
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
pip install --no-index --find-links wheelhouse ${{ env.PROJECT_NAME }}
pytest
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
pip install ${{ env.BUILD_DEPENDS }}
- 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 @@ -159,6 +154,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 @@ -171,15 +167,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,3 +0,0 @@
[submodule "multibuild"]
path = multibuild
url = https://github.com/matthew-brett/multibuild
16 changes: 0 additions & 16 deletions config.sh

This file was deleted.

1 change: 0 additions & 1 deletion multibuild
Submodule multibuild deleted from 938d95
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ requires = [
"setuptools",
"wheel",
"setuptools_scm",
"setuptools_scm_git_archive",
"cython",
]

build-backend = "setuptools.build_meta"
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[metadata]
description_file = README.rst

[sdist]
formats = zip

[aliases]
test = pytest

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class sdist(_sdist):
"""
def run(self):
from Cython.Build import cythonize
cythonize(sources, language='c++')
cythonize(sources, language_level="2")
_sdist.run(self)

cmdclass = {'sdist': sdist, 'build_ext': build_ext}
Expand Down Expand Up @@ -67,6 +67,7 @@ def run(self):
use_scm_version={"write_to": "src/pyclipper/_version.py"},
description='Cython wrapper for the C++ translation of the Angus Johnson\'s Clipper library (ver. 6.4.2)',
long_description=long_description,
long_description_content_type="text/x-rst",
author='Angus Johnson, Maxime Chalton, Lukas Treyer, Gregor Ratajc',
author_email='me@gregorratajc.com',
maintainer="Cosimo Lupo",
Expand Down
1 change: 1 addition & 0 deletions src/pyclipper/_pyclipper.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# distutils: language=c++
"""
Cython wrapper for the C++ translation of the Angus Johnson's Clipper
library (ver. 6.2.1) (http://www.angusj.com/delphi/clipper.php)
Expand Down

0 comments on commit 2ec1236

Please sign in to comment.