linkcell 0.3.11

Periodic linked-cell cutoff pairs and k-nearest neighbour search
Documentation
name: wheels

on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
    paths:
      - "python/**"
      - "linkcell/**"
      - "pyproject.toml"
      - "Cargo.toml"
      - "Cargo.lock"
      - "src/**"
      - "third_party/**"
      - "include/**"
      - ".github/workflows/wheels.yml"

concurrency:
  group: wheels-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  # One abi3 wheel per platform (CPython 3.12+ GIL).
  abi3:
    name: abi3 ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: linux-x86_64
            os: ubuntu-latest
            arch: x86_64
          - name: linux-aarch64
            os: ubuntu-24.04-arm
            arch: aarch64
          - name: macos-arm64
            os: macos-latest
            arch: arm64
          - name: windows-x86_64
            os: windows-latest
            arch: AMD64
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
      - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
        with:
          python-version: "3.12"
          cache-suffix: abi3-${{ matrix.arch }}
      - name: Build abi3 wheel
        run: uvx --from 'cibuildwheel>=4,<5' cibuildwheel --output-dir wheelhouse
        env:
          CIBW_BUILD: "cp312-*"
          CIBW_SKIP: "*musllinux* *i686* cp3??t-*"
          CIBW_ARCHS: ${{ matrix.arch }}
          CIBW_ENVIRONMENT: MATURIN_PEP517_ARGS="--features abi3"
          CIBW_TEST_REQUIRES: pytest numpy
          CIBW_TEST_COMMAND: pytest {project}/tests/python -q
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels-abi3-${{ matrix.name }}
          path: ./wheelhouse/*.whl

  # One abi3t wheel per platform (CPython 3.15+ GIL and free-threaded).
  # abi3audit --strict still treats PEP 793 PyModExport / PyType_FromSlots
  # as non-abi3, so the audit step is off for this job only.
  abi3t:
    name: abi3t ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: linux-x86_64
            os: ubuntu-latest
            arch: x86_64
          - name: linux-aarch64
            os: ubuntu-24.04-arm
            arch: aarch64
          - name: macos-arm64
            os: macos-latest
            arch: arm64
          - name: windows-x86_64
            os: windows-latest
            arch: AMD64
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
      - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
        with:
          python-version: "3.15"
          cache-suffix: abi3t-${{ matrix.arch }}
      - name: Build abi3t wheel
        run: uvx --from 'cibuildwheel>=4,<5' cibuildwheel --output-dir wheelhouse
        env:
          CIBW_BUILD: "cp315-*"
          CIBW_SKIP: "*musllinux* *i686* cp3??t-*"
          CIBW_ARCHS: ${{ matrix.arch }}
          CIBW_ENVIRONMENT: MATURIN_PEP517_ARGS="--features abi3t"
          CIBW_AUDIT_COMMAND: ""
          CIBW_TEST_REQUIRES: pytest numpy
          CIBW_TEST_COMMAND: pytest {project}/tests/python -q
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels-abi3t-${{ matrix.name }}
          path: ./wheelhouse/*.whl

  sdist:
    name: Source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
      - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
        with:
          python-version: "3.12"
          cache-suffix: sdist
      - name: Build sdist
        run: uvx maturin sdist --out dist
      - name: Test installed sdist
        run: |
          uv venv --clear .sdist-venv
          uv pip install --python .sdist-venv/bin/python dist/*.tar.gz pytest numpy
          .sdist-venv/bin/python -I -c "import linkcell; print(linkcell.__file__)"
          .sdist-venv/bin/python -I -m pytest --import-mode=importlib "$PWD/tests/python" -q
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: sdist
          path: dist/*.tar.gz

  # Trusted publisher: PyPI project linkcell, repo d-SEAMS/linkcell,
  # workflow wheels.yml, environment (Any). Do not set `environment:`
  # on this job.
  publish:
    name: Publish to PyPI
    needs: [abi3, abi3t, sdist]
    runs-on: ubuntu-latest
    if: >-
      github.repository == 'd-SEAMS/linkcell' &&
      github.event_name == 'push' &&
      startsWith(github.ref, 'refs/tags/v')
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          path: dist
          merge-multiple: true
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
        with:
          packages-dir: dist/