Skip to content

Ensure we use ccache on macos and linux #334

Ensure we use ccache on macos and linux

Ensure we use ccache on macos and linux #334

Workflow file for this run

name: Build and test wheels on multiple platforms
on:
release:
types: [published]
push:
pull_request:
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build sdist
run: pipx run build --sdist
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: cibw-sdist
path: dist/*.tar.gz
build_wheels:
name: ${{ matrix.os }} ${{ matrix.CIBW_ARCHS }} wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
CIBW_ENVIRONMENT: ''
CIBW_ARCHS: "x86_64"
CIBW_PLATFORM: "auto"
- os: ubuntu-latest
CIBW_ENVIRONMENT: ''
CIBW_ARCHS: "wasm32"
CIBW_PLATFORM: "pyodide"
- os: ubuntu-24.04-arm
CIBW_ENVIRONMENT: ''
CIBW_ARCHS: "aarch64"
CIBW_PLATFORM: "auto"
- os: windows-latest
CIBW_ENVIRONMENT: ''
CIBW_ARCHS: "AMD64"
CIBW_PLATFORM: "auto"
- os: macos-15-intel
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET='13.0'
CIBW_ARCHS: "x86_64"
CIBW_PLATFORM: "auto"
- os: macos-14 # Apple Silicon
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET='13.0'
CIBW_ARCHS: "arm64"
CIBW_PLATFORM: "auto"
env:
CIBW_ENVIRONMENT: ${{ matrix.CIBW_ENVIRONMENT }}
CIBW_SKIP: "*-win32 *i686"
CIBW_ARCHS: ${{ matrix.CIBW_ARCHS }}
CIBW_PLATFORM: ${{ matrix.CIBW_PLATFORM }}
CIBW_ENVIRONMENT_MACOS: PATH=/usr/local/opt/ccache/libexec:/opt/homebrew/opt/ccache/libexec:$PATH
CIBW_ENVIRONMENT_LINUX: PATH=/usr/local/bin:/usr/lib/ccache:$PATH CCACHE_DIR=/host${{ github.workspace }}/.ccache CCACHE_CONFIGPATH=/host/home/runner/.config/ccache/ccache.conf
CIBW_BEFORE_BUILD_MACOS: brew install ccache zlib
CIBW_PRERELEASE_PYTHONS: "True"
# see https://github.com/matplotlib/matplotlib/pull/28687/files#diff-504e739c530d50b780e9a09ae8fd0c3ea8258ea7553be06afb06f03f95b1ee0aR103
CIBW_CONFIG_SETTINGS_WINDOWS: >-
setup-args="--vsenv"
setup-args="-Db_vscrt=mt"
setup-args="-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']"
steps:
- uses: actions/checkout@v6
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.CIBW_ARCHS }} # Make cache specific to OS/ARCH
max-size: "5G"
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.0
- uses: actions/upload-artifact@v5
with:
name: cibw-wheels-${{ matrix.os }}-${{ matrix.CIBW_ARCHS }}
path: ./wheelhouse/*.whl
test_wheels:
needs: [build_wheels]
strategy:
matrix:
os: [macos-15-intel, windows-latest, ubuntu-latest, ubuntu-24.04-arm]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
runs-on: ${{ matrix.os }}
steps:
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
#architecture: x64
- uses: actions/download-artifact@v6
with:
pattern: cibw-wheels-*
path: dist
merge-multiple: true
- name: install wheel (Unix)
if: runner.os != 'Windows'
run: |
pip install numpy pyyaml
pip install --no-index --find-links $GITHUB_WORKSPACE/dist pycdfpp
- name: install wheel (Windows)
if: runner.os == 'Windows'
run: |
pip install numpy pyyaml
pip install --no-index --find-links $env:GITHUB_WORKSPACE\dist pycdfpp
- uses: actions/checkout@v6
- name: run tests
run: |
pip install ddt requests
python -v tests/full_corpus/test_full_corpus.py
test_wheels_macos_14:
needs: [build_wheels]
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
runs-on: macos-14
steps:
- name: add pyenv to path
run: |
echo "~/.pyenv/shims" >> $GITHUB_PATH
- name: install dependencies
run: |
brew update
brew install pyenv --head
pyenv install ${{ matrix.python-version }}
- uses: actions/download-artifact@v6
with:
pattern: cibw-wheels-*
path: dist
merge-multiple: true
- name: install wheel
run: |
pyenv local ${{ matrix.python-version }}
python3 -m pip install --break-system-packages numpy pyyaml
python3 -m pip install --break-system-packages --no-index --find-links $GITHUB_WORKSPACE/dist pycdfpp
- uses: actions/checkout@v6
- name: run tests
run: |
pyenv local ${{ matrix.python-version }}
python3 -m pip install --break-system-packages ddt requests
python3 tests/full_corpus/test_full_corpus.py
upload_pypi:
needs: [build_sdist, build_wheels, test_wheels, test_wheels_macos_14]
runs-on: ubuntu-latest
# upload to PyPI only on github releases
environment:
name: pypi
url: https://pypi.org/p/pycdfpp
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published' && github.repository_owner == 'SciQLop'
steps:
- uses: actions/download-artifact@v6
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Remove wasm32 wheels (until PyPI PEP 783 is implemented)
run: find dist -name "*wasm32.whl" -delete
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
upload_test_pypi:
needs: [build_sdist, build_wheels, test_wheels, test_wheels_macos_14]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/project/pycdfpp
permissions:
id-token: write
# upload to test PyPI on github pushes
if: github.event_name == 'push' && github.repository_owner == 'SciQLop'
steps:
- uses: actions/download-artifact@v6
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Remove wasm32 wheels (until PyPI PEP 783 is implemented)
run: find dist -name "*wasm32.whl" -delete
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true