Skip to content

Refactor pre-commit. #2698

Refactor pre-commit.

Refactor pre-commit. #2698

Workflow file for this run

name: Build wheels
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- "main"
- "next"
tags:
- "*"
pull_request:
workflow_dispatch:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
build_wheels:
name: Build wheels [${{ matrix.python.version }}, ${{ matrix.os.base }}-${{ matrix.os.arch }}]
runs-on: ${{ matrix.os.base }}-${{ matrix.os.version }}
strategy:
fail-fast: false
matrix:
os:
- base: ubuntu
version: latest
arch: 'x86_64'
# - base: windows
# version: latest
# arch: 'amd64'
- base: macos
version: 14
arch: 'arm64'
- base: macos
version: 13
arch: 'x86_64'
python:
# Pinned versions installed in CIBW_TEST_REQIURES are kept. Those defined installed in
# CIBW_BEFORE_TEST are often upgraded when the wheel is installed. This means we can't
# store the pinned requirements in a requirements file.
# Generate these version sets with commands like this:
# echo -e "numpy==1.21.6\nscipy\ngsd\nmatplotlib\nsympy" | uv pip compile --python-platform linux --python-version 3.9 --only-binary :all: - --resolution=lowest --no-deps
- version: 'cp39'
oldest_numpy: '1.22.4'
oldest_scipy: '1.7.3'
oldest_gsd: '2.5.0'
oldest_matplotlib: '3.5.0'
oldest_pytest: '8.2.1'
oldest_sympy: '1.10'
- version: 'cp310'
oldest_numpy: '1.22.4'
oldest_scipy: '1.7.3'
oldest_gsd: '2.7.0'
oldest_matplotlib: '3.5.0'
oldest_pytest: '8.2.1'
oldest_sympy: '1.10'
- version: 'cp311'
oldest_numpy: '1.23.2'
oldest_scipy: '1.9.2'
oldest_gsd: '2.7.0'
oldest_matplotlib: '3.6.0'
oldest_pytest: '8.2.1'
oldest_sympy: '1.10'
- version: 'cp312'
oldest_numpy: '1.26.2'
oldest_scipy: '1.11.2'
oldest_gsd: '3.2.0'
oldest_matplotlib: '3.7.3'
oldest_pytest: '8.2.1'
oldest_sympy: '1.10'
steps:
- name: checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: "recursive"
- name: Build wheels
uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # v2.20.0
env:
CIBW_BUILD: "${{ matrix.python.version }}-*"
CIBW_SKIP: "{pp*,*-musllinux_*}"
# Build only on 64-bit architectures.
CIBW_ARCHS: auto64
# Configure environment variables.
CIBW_ENVIRONMENT_LINUX: "CMAKE_PREFIX_PATH=/project/tbb LD_LIBRARY_PATH=/project/tbb/lib/intel64/gcc4.8:$LD_LIBRARY_PATH CMAKE_ARGS=-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=True"
CIBW_ENVIRONMENT_MACOS: "CMAKE_PREFIX_PATH=/Users/runner/work/freud/freud/tbb:/Users/runner/work/tbb-install CMAKE_ARGS=-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=True"
MACOSX_DEPLOYMENT_TARGET: "10.14"
# Set up TBB.
CIBW_BEFORE_BUILD_LINUX: "source .github/workflows/cibuildwheel-before-build.sh {package} linux"
CIBW_BEFORE_BUILD_MACOS: "source .github/workflows/cibuildwheel-before-build.sh {package} macos"
CIBW_BEFORE_BUILD_WINDOWS: "powershell .github/workflows/cibuildwheel-before-build.ps1 {package}"
# Test the wheels.
CIBW_TEST_REQUIRES: >
pytest==${{ matrix.python.oldest_pytest }}
sympy==${{ matrix.python.oldest_sympy }}
numpy==${{ matrix.python.oldest_numpy }}
scipy==${{ matrix.python.oldest_scipy }}
gsd==${{ matrix.python.oldest_gsd }}
matplotlib==${{ matrix.python.oldest_matplotlib }}
# Test only the currently ported modules
CIBW_TEST_COMMAND: "cd {package}/tests && pytest test_box_Box.py test_parallel.py -v --log-level=DEBUG"
# CIBW_TEST_COMMAND: "cd {package}/tests && pytest . -v --log-level=DEBUG"
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: dist-${{ matrix.os.base }}-${{ matrix.os.version }}-${{ matrix.python.version }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: "recursive"
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.12"
- name: Set up Python environment
uses: glotzerlab/workflows/setup-uv@ae7e7c6931098a313ef8069ef04b88a55c3a40f6 # 0.3.0
with:
lockfile: ".github/requirements-build-sdist.txt"
- name: Build sdist
run: python -m build --sdist --outdir dist/ .
- name: Check sdist size
run: du -hs dist/*
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: dist-sdist
path: dist/*.tar.gz
upload_pypi:
name: Publish [PyPI]
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
concurrency: upload
steps:
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
merge-multiple: 'true'
pattern: dist-*
path: dist
- name: Check files
run: ls -lR dist
- name: Upload to PyPI
# upload to PyPI on every tag starting with 'v'
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Slack notification
if: startsWith(github.ref, 'refs/tags/v') || failure()
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
channel: '#dev-freud'