Skip to content

Publish PyKLU to testPyPI #9

Publish PyKLU to testPyPI

Publish PyKLU to testPyPI #9

name: Publish PyKLU to testPyPI
on:
workflow_dispatch:
jobs:
build-wheels:
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-15-intel, macos-latest]
pyver: [cp39, cp310, cp311, cp312, cp313, cp314]
steps:
- name: Check out source (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel
run: python -m pip install --upgrade pip cibuildwheel
- name: Build wheels with cibuildwheel
run: python -m cibuildwheel --output-dir wheelhouse
env:
# Build for these CPython versions
CIBW_BUILD: ${{ matrix.pyver }}-*
# Linux: run inside manylinux containers, use yum
CIBW_BEFORE_BUILD_LINUX: |
yum install -y openblas-devel || true
python -m pip install --upgrade pip
python -m pip install cmake numpy scipy
# macOS: runs directly on the macOS runner, use Homebrew
CIBW_BEFORE_BUILD_MACOS: |
brew install openblas || true
python -m pip install --upgrade pip
python -m pip install cmake numpy scipy
# Skip 32-bit & musllinux if you don’t care about them
CIBW_SKIP: "cp3?-manylinux_i686 *musllinux*"
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl
build-windows:
name: Build wheels for Windows
runs-on: windows-latest
strategy:
matrix:
pyver: [cp39, cp310, cp311, cp312, cp313, cp314]
steps:
- name: Check out source (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: build
auto-activate-base: false
use-mamba: true
- name: Install build dependencies (conda)
shell: bash -l {0}
run: |
conda install -c conda-forge -y suitesparse openblas
# Optional but often handy
conda install -c conda-forge -y cmake
- name: Capture conda prefix
shell: bash -l {0}
run: |
echo "CONDA_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
echo "Using CONDA_PREFIX=$CONDA_PREFIX"
- name: Set up Python for cibuildwheel
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel + repair tool
run: python -m pip install --upgrade pip cibuildwheel delvewheel
- name: Build wheels with cibuildwheel
run: python -m cibuildwheel --output-dir wheelhouse
env:
# Choose what you actually want to ship.
CIBW_BUILD: ${{ matrix.pyver }}-*
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_ENVIRONMENT_WINDOWS: >
CONDA_PREFIX=C:\\Miniconda\\envs\\build
# Ensure numpy/cython/etc exist in each build env (cibuildwheel makes isolated envs)
CIBW_BEFORE_BUILD_WINDOWS: >
python -m pip install --upgrade pip &&
python -m pip install cython numpy delvewheel
# Bundle DLL deps into the wheel so users don't need conda
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
python -m delvewheel repair -w {dest_dir} {wheel}
--add-path C:\Miniconda\envs\build\Library\bin
# Optional quick import test
CIBW_TEST_COMMAND: python -c "import PyKLU; import PyKLU._klu; print(PyKLU.__version__)"
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ strategy.job-index }}
path: wheelhouse/*.whl
build-sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build
run: python -m pip install --upgrade pip build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
publish-to-testpypi:
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist, build-windows]
environment:
name: testpypi
url: https://test.pypi.org/project/pyklu/
permissions:
id-token: write
steps:
- name: Download wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Show files to be uploaded
run: ls -R dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true