Skip to content

feat: add support for python 3.13 #563

feat: add support for python 3.13

feat: add support for python 3.13 #563

Workflow file for this run

name: "Presubmit: build and test wheels"
on:
pull_request:
branches:
- main
jobs:
mypy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install nox
run: |
python -m ensurepip
python -m pip install nox
- name: Run mypy
env:
# workaround for https://github.com/pypa/setuptools/issues/3557
SETUPTOOLS_ENABLE_FEATURES: legacy-editable
run: |
nox -s mypy
build-wheels-linux:
name: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build Wheels
uses: pypa/cibuildwheel@v2.20.0
env:
# 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/
build-wheels-macos:
name: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-13
# Wheels port forward
#- macos-11
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
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@v3
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.20.0
env:
# 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/
build-wheels-windows:
name: ${{ matrix.os }} ( ${{ matrix.platform }} )
strategy:
matrix:
os:
- windows-2022
platform:
# For presubmit, just build / test the most common platform
- x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
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@v3
with:
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
python -m pip install cmake
echo "::endgroup::"
echo "::group::Run cmake to initialze build tree"
cmake -S google_crc32c -B build -G "Visual Studio 17 2022" -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: |
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: |
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.20.0
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