Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build wheels using CIBuildWheel #103

Merged
merged 53 commits into from Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0867591
ci: try using cibuildwheel
tseaver Sep 9, 2021
8995707
ci: consolidate jobs
tseaver Sep 9, 2021
330bda4
fix: use container-relative install prefix
tseaver Sep 9, 2021
cfbfd06
fix: make cibuildwheel run verbosely
tseaver Sep 9, 2021
6bf2e6c
fix: dead reckoning from install prefix
tseaver Sep 9, 2021
33eb5f2
ci: must build library in container
tseaver Sep 9, 2021
8ca15dc
ci: use 'wheelhouse' for artifacts
tseaver Sep 9, 2021
e601df8
ci: test built wheels
tseaver Sep 9, 2021
16d9676
ci: enable macos wheel builds
tseaver Sep 9, 2021
33d16ce
ci: try building C lib on windows
tseaver Sep 10, 2021
9c89e65
restore linux / macos builds
tseaver Sep 10, 2021
401348a
ci: try building from default prefix on Windows
tseaver Sep 13, 2021
8ef4d88
ci: try building from default prefix on Windows moar
tseaver Sep 13, 2021
73fdf57
ci: try building from default prefix on Windows harder
tseaver Sep 13, 2021
6ac948e
ci: debug installed prefix on Windows
tseaver Sep 13, 2021
5774c22
ci: disable pure-Python build under CIBW
tseaver Sep 13, 2021
e623c72
ci: 'runtime_library_dirs' borks on Windows
tseaver Sep 13, 2021
636fd7e
ci: moar tracer bullitz
tseaver Sep 13, 2021
56c9f15
ci: 'runtime_library_dirs' borks on Windows moar
tseaver Sep 13, 2021
20a396f
ci: try pre-building extension on Windows
tseaver Sep 13, 2021
dbfbf7d
ci: debug copying library DLL into project
tseaver Sep 13, 2021
12a31b7
ci: try rationalizing 'copy_dll' dance
tseaver Sep 13, 2021
f173dce
ci: try static build of C library.
tseaver Sep 13, 2021
732d832
ci: go back to explicit install prefix for C library
tseaver Sep 13, 2021
e6aa137
ci: build only AMD64 wheel
tseaver Sep 13, 2021
c9846f8
ci: use platform-specific install prefix for C library
tseaver Sep 13, 2021
48be970
ci: tweak setting install prefix
tseaver Sep 13, 2021
f7c2a3e
ci: tweak archs, install prefix
tseaver Sep 13, 2021
0830744
ci: use envvar everywhere
tseaver Sep 13, 2021
4c5fe57
ci: use envvar everywhere moar
tseaver Sep 13, 2021
067afde
ci: cache C library build
tseaver Sep 13, 2021
2254fb1
ci: don't use platform in lib prefix
tseaver Sep 13, 2021
ecc113e
ci: fix c library cache test
tseaver Sep 13, 2021
261c324
ci: tweak CIBW_ARCHS setting
tseaver Sep 13, 2021
c3d39b4
ci: restore linux / macos builds
tseaver Sep 13, 2021
5672753
ci: cache MacOS library build
tseaver Sep 14, 2021
75b8d69
ci: test dir-ness after build / cache load
tseaver Sep 14, 2021
fd709af
ci: try to synthesize forward-slash-only prefix
tseaver Sep 14, 2021
3599f6e
ci: raw string literal
tseaver Sep 14, 2021
77dfa5b
ci: set prefix output var
tseaver Sep 14, 2021
c07b78e
ci: document the workarounds
tseaver Sep 14, 2021
e7cad0c
ci: polish presubmit
tseaver Sep 14, 2021
e3edb94
ci: restore original workflow filename
tseaver Sep 14, 2021
52d358c
ci: skip PyPy build on presubmit
tseaver Sep 14, 2021
28ddef6
ci: skip universal wheel for presubmit
tseaver Sep 14, 2021
fd8530b
ci: configure GHA job for building all wheels, pushing to PyPI
tseaver Sep 16, 2021
f95382a
ci: test release build on PR branch
tseaver Sep 16, 2021
0a23fc7
chore: configure qeumu for cross-compiles
tseaver Sep 16, 2021
45d6ff5
fix: typo
tseaver Sep 16, 2021
43d1e16
ci: split linux / macos builds by arch
tseaver Sep 16, 2021
880b2f8
ci: s/arg/arch/
tseaver Sep 16, 2021
bc9a4a8
ci: remove running 'python-publish' workflow on push
tseaver Sep 16, 2021
2ea95c5
ci: tweak required builds for presubmit
tseaver Sep 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
252 changes: 159 additions & 93 deletions .github/workflows/presubmit.yml
@@ -1,134 +1,200 @@

name: Presubmit
name: Build / test wheels (presubmit)

on:
pull_request:
branches:
- main

jobs:
build-source-distribution:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Build
run: python setup.py sdist
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist

build-linux:
runs-on: ubuntu-latest
build-wheels-linux:
name: Build / test wheels on ${{ matrix.os }}
strategy:
matrix:
# 3.10 is not yet available in manylinux docker images.
# https://github.com/pypa/manylinux
# python: [3.6, 3.7, 3.8, 3.9, 3.10-dev]
python: [3.6, 3.7, 3.8, 3.9, 3.10-dev]
# It is possible 3.10-dev will fail when the other versions are green.
# Turn off fast fail so if 3.10 fails the other required versions have
# the opportunity to pass.
fail-fast: false
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools pip wheel
- name: Build
submodules: 'recursive'

- name: Build Wheels
uses: pypa/cibuildwheel@v2.1.1
env:
BUILD_PYTHON: ${{ matrix.python }}
CRC32C_PURE_PYTHON: "0"
run: |
./scripts/manylinux/build.sh
- name: Test Import
run: |
pip install --no-index --find-links=wheels google-crc32c
python ./scripts/check_crc32c_extension.py
- name: Run tests
run: |
pip install pytest
python -m pytest tests
# For presubmit, just build / test the most common arch
CIBW_ARCHS: native
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
# Build the C library inside CIBW so that the manylinux image is
# used to link the share library; otherwise, our extension wouldn't
# be able to link with it.
CIBW_BEFORE_BUILD: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr &&
make -C build all install
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/

- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: ./wheels/google_crc32c*.whl
path: wheelhouse/

build-macos:
runs-on: macos-latest
build-wheels-macos:
name: Build / test wheels on ${{ matrix.os }}
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, 3.10-dev]
# It is possible 3.10-dev will fail when the other versions are green.
# Turn off fast fail so if 3.10 fails the other required versions have
# the opportunity to pass.
fail-fast: false
os:
- macos-10.15
# Wheels port forward
#- macos-11
runs-on: ${{ matrix.os }}
steps:

- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools pip wheel
- name: Build
submodules: 'recursive'

- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"

- id: load-cache
name: Load cached C library
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/usr
key:
libcrc32c-${{ matrix.os }}-${{ steps.get-c-lib-hash.outputs.hash }}

- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/usr \
-DCMAKE_INSTALL_NAME_DIR:PATH=${{ github.workspace }}/usr/lib &&
make -C build all install

- name: Build Wheels
uses: pypa/cibuildwheel@v2.1.1
env:
CRC32C_PURE_PYTHON: "0"
run: |
./scripts/osx/build_gh_action.sh
- name: Test Import
run: |
pip install --no-index --find-links=wheels google-crc32c
python ./scripts/check_crc32c_extension.py
- name: Run tests
run: |
pip install pytest
python -m pytest tests
# For presubmit, just build / test the most common arch
CIBW_ARCHS: native
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/

- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: ./wheels/google_crc32c*.whl
path: wheelhouse/

build-wheels-windows:
name: Build / test wheels on ${{ matrix.os }} ( ${{ matrix.platform }} )

build-windows:
runs-on: windows-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, 3.10-dev]
# It is possible 3.10-dev will fail when the other versions are green.
# Turn off fast fail so if 3.10 fails the other required versions have
# the opportunity to pass.
fail-fast: false
os:
- windows-2019
platform:
# For presubmit, just build / test the most common platform
- x64
#- Win32

runs-on: ${{ matrix.os }}

steps:

- uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
with:
# Use 16.x
vs-version: '[16.0, 17.0)'
- name: Set up Python
uses: actions/setup-python@v2
submodules: 'recursive'

- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"

- id: load-cache
name: Load cached C library
uses: actions/cache@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
path: ${{ github.workspace }}\usr
key:
libcrc32c-${{ matrix.os }}-${{ matrix.platform }}-${{ steps.get-c-lib-hash.outputs.hash }}

- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: |
echo "::group::Install cmake"
python -m pip install --upgrade setuptools pip wheel
- name: Build
env:
CRC32C_PURE_PYTHON: "0"
python -m pip install cmake
echo "::endgroup::"
echo "::group::Run cmake to initialze build tree"
cmake -S google_crc32c -B build -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0
echo "::endgroup::"
echo "::group::Run cmake to build library"
cmake --build build --verbose --config Release
echo "::endgroup::"
echo "::group::Run cmake to install library"
cmake --install build --verbose --config Release --prefix=${{ github.workspace }}\usr\
echo "::endgroup::"

# Passing through ${{ github.workspace }} to CIBW_ENVIRONMENT mangles
# backslashes: compute a variant which uses only forward-slashses.
- id: crc32c-install-prefix
name: Dead-reckon a CIBW-compatible install prefix
shell: bash
run: |
where python
./scripts/windows/build.bat ${{ matrix.python }}
- name: Test Import
python -c "import os; workspace = '/'.join(os.getenv('GITHUB_WORKSPACE').split(os.sep)); pfx = f'{workspace}/usr'; print(f'::set-output name=prefix::{pfx}')"

- id: platform-arch
name: Map platform -> wheel arch
shell: bash
run: |
./scripts/windows/test.bat ${{ matrix.python }}
if [[ "${{ matrix.platform }}" == "Win32" ]]; then
echo "::set-output name=arch::x86"
else
echo "::set-output name=arch::AMD64"
fi

- name: Build Wheels
uses: pypa/cibuildwheel@v2.1.1
env:
CIBW_ARCHS_WINDOWS: ${{ steps.platform-arch.outputs.arch }}
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: CRC32C_PURE_PYTHON="0" CRC32C_INSTALL_PREFIX="${{ steps.crc32c-install-prefix.outputs.prefix }}"
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests

- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: ./wheels/google_crc32c*.whl
path: wheelhouse/