Skip to content

Commit

Permalink
Use cibuildwheel to build release wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
elprans committed Aug 10, 2021
1 parent 4f22ad3 commit 2f57b6b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 107 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/build-manylinux-wheels.sh

This file was deleted.

113 changes: 50 additions & 63 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
mkdir -p dist/
echo "${VERSION}" > dist/VERSION
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
Expand All @@ -47,111 +47,98 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 50
submodules: true

- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up Python
uses: actions/setup-python@v2

- name: Build source distribution
run: |
pip install -U setuptools wheel pip
python -m pip install -U setuptools wheel pip
python setup.py sdist
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
path: dist/*.tar.*

build-wheels:
needs: validate-release-request
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
os: [ubuntu-20.04, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
cibw_arch: ["auto64", "aarch64", "universal2"]
cibw_python:
- "cp36-*"
- "cp37-*"
- "cp38-*"
- "cp39-*"
- "cp310-*"
exclude:
# Python 3.5 is unable to properly
# find the recent VS tooling
# https://bugs.python.org/issue30389
- os: ubuntu-latest
cibw_arch: universal2
- os: macos-latest
cibw_arch: aarch64
- os: macos-latest
cibw_python: "cp36-*"
cibw_arch: universal2
- os: macos-latest
cibw_python: "cp37-*"
cibw_arch: universal2
- os: windows-latest
cibw_arch: universal2
- os: windows-latest
python-version: 3.5
cibw_arch: aarch64

defaults:
run:
shell: bash

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 50
submodules: true

- uses: actions/download-artifact@v1
with:
name: dist
path: dist/

- name: Extract Release Version
id: relver
run: |
set -e
echo ::set-output name=version::$(cat dist/VERSION)
rm dist/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install Python Deps
run: |
python -m pip install --upgrade setuptools pip wheel
- name: Build Wheels (linux)
if: startsWith(matrix.os, 'ubuntu')
uses: docker://quay.io/pypa/manylinux1_x86_64
env:
PYTHON_VERSION: ${{ matrix.python-version }}
- name: Set up QEMU
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
uses: docker/setup-qemu-action@v1
with:
entrypoint: /github/workspace/.github/workflows/build-manylinux-wheels.sh

- name: Build Wheels (non-linux)
if: "!startsWith(matrix.os, 'ubuntu')"
run: |
make clean
python setup.py bdist_wheel
platforms: arm64

- name: Test Wheels
if: |
!startsWith(matrix.os, 'windows')
&& !contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
- uses: pypa/cibuildwheel@v2.1.1
env:
OS: ${{ matrix.os }}
PKG_VERSION: ${{ steps.relver.outputs.version }}
run: |
"${GITHUB_WORKSPACE}/.github/workflows/test-wheels.sh"
- uses: actions/upload-artifact@v1
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.cibw_python }}
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "python {project}/tests/__init__.py"
CIBW_TEST_COMMAND_WINDOWS: "python {project}\\tests\\__init__.py"
CIBW_TEST_SKIP: "*universal2:arm64"

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

publish:
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 5
submodules: false

- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v2
with:
name: dist
path: dist/
Expand Down Expand Up @@ -181,7 +168,7 @@ jobs:
release_name: v${{ steps.relver.outputs.version }}
target: ${{ github.event.pull_request.base.ref }}
body: ${{ github.event.pull_request.body }}
draft: true
draft: false

- run: |
ls -al dist/
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/test-wheels.sh

This file was deleted.

18 changes: 10 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,31 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
os: [windows-latest, ubuntu-18.04, macos-latest]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0-rc.1]
os: [windows-latest, ubuntu-latest, macos-latest]
exclude:
# Python 3.5 is unable to properly
# find the recent VS tooling
# https://bugs.python.org/issue30389
- os: windows-latest
python-version: 3.5

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 50
submodules: true

- name: Check if release PR.
uses: edgedb/action-release/validate-pr@master
continue-on-error: true
id: release
with:
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
missing_version_ok: yes
version_file: httptools/_version.py
version_line_pattern: |
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
Expand All @@ -49,6 +51,6 @@ jobs:
- name: Test
if: steps.release.outputs.version == 0
run: |
pip install -U pip setuptools wheel
pip install -e .[test]
python setup.py test
python -m pip install -U pip setuptools wheel
python -m pip install -e .[test]
python -m unittest -v tests.suite
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def parse_url(url: bytes):
1. Clone this repository with
`git clone --recursive git@github.com:MagicStack/httptools.git`

2. Create a virtual environment with Python 3.5:
`python3.5 -m venv envname`
2. Create a virtual environment with Python 3:
`python3 -m venv envname`

3. Activate the environment with `source envname/bin/activate`

4. Install Cython with `pip install cython`
4. Install development requirements with `pip install -e .[test]`

5. Run `make` and `make test`.

Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
addopts = --capture=no --assert=plain --strict --tb native
addopts = --capture=no --assert=plain --strict-markers --tb=native --import-mode=importlib
testpaths = tests
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def build_extensions(self):
'Development Status :: 5 - Production/Stable',
],
platforms=['macOS', 'POSIX', 'Windows'],
python_requires='>=3.5.0',
zip_safe=False,
author='Yury Selivanov',
author_email='yury@magic.io',
Expand Down

0 comments on commit 2f57b6b

Please sign in to comment.