racah 0.2.0

Racah-Wigner calculus for compact Lie groups: exact SU(2) recoupling, and runtime Clebsch-Gordan / F- / R-coefficient generation for SU(N), SO(N), and Sp(2N)
Documentation
name: wheels

# Python bindings (`racah-py`): abi3-py312 wheels for linux (x86_64, aarch64),
# macos (arm64, x86_64), windows (x86_64), plus an sdist.
#
# Trusted publishing (OIDC, no tokens), same ladder as tenet-py's release.yml:
# a `py-v*` tag push dry-runs the artifacts through TestPyPI; publishing a
# GitHub release whose tag starts with `py-v` ships them to PyPI. The crate's
# own `v*` releases never touch PyPI, so the two cadences stay independent.
on:
  push:
    branches: [main]
    tags: ["py-v*"]
  pull_request:
  release:
    types: [published]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  # Build the extension in place and run the Python smoke tests.
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: rustup toolchain install stable --profile minimal
      - uses: Swatinem/rust-cache@v2
      - run: pip install maturin pytest numpy
      # `maturin develop` needs an activated virtualenv; the runner's Python is
      # already isolated, so build the wheel and install it.
      - run: maturin build --release --manifest-path racah-py/Cargo.toml --out dist
      - run: pip install --no-index --find-links dist racah-py
      - run: pytest racah-py/tests -q

  wheels:
    if: >-
      startsWith(github.ref, 'refs/tags/py-v') ||
      github.event_name == 'workflow_dispatch' ||
      (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'py-v'))
    strategy:
      fail-fast: false
      matrix:
        include:
          # linux aarch64 cross-compiles inside maturin-action's manylinux
          # docker image; macos x86_64 cross-compiles from the arm64 runner.
          # The crate is pure Rust, so stock toolchains suffice everywhere.
          - runner: ubuntu-latest
            target: x86_64
          - runner: ubuntu-latest
            target: aarch64
          - runner: macos-14
            target: aarch64
          - runner: macos-14
            target: x86_64
          - runner: windows-latest
            target: x64
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          # abi3-py312: one wheel per platform covers CPython >= 3.12.
          args: --release --out dist --manifest-path racah-py/Cargo.toml
          manylinux: auto
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.runner }}-${{ matrix.target }}
          path: dist

  # Unsupported platforms build from source with a Rust toolchain.
  sdist:
    if: >-
      startsWith(github.ref, 'refs/tags/py-v') ||
      github.event_name == 'workflow_dispatch' ||
      (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'py-v'))
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist --manifest-path racah-py/Cargo.toml
      - uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist

  publish:
    needs: [wheels, sdist]
    if: >-
      startsWith(github.ref, 'refs/tags/py-v') ||
      (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'py-v'))
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true
      - if: github.event_name == 'push'
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          repository-url: https://test.pypi.org/legacy/
      - if: github.event_name == 'release'
        uses: pypa/gh-action-pypi-publish@release/v1