Skip to content

TileDB-SOMA Python Release #1764

TileDB-SOMA Python Release

TileDB-SOMA Python Release #1764

# Workflow to build distribution, and push to PyPI or TestPyPI
name: TileDB-SOMA Python Release
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/python-packaging.yml'
release:
types: [published]
schedule:
- cron: "42 9 * * *"
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-24.04
steps:
- name: Checkout TileDB-SOMA
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch tags: https://github.com/actions/checkout/issues/2199
fetch-tags: true # Tags needed for python API version number
- name: Install dependencies
run: |
pip install --upgrade 'setuptools>=70.1' importlib-metadata # cf. https://github.com/single-cell-data/TileDB-SOMA/pull/3076
pip list
- name: Build sdist
working-directory: apis/python
run: python setup.py sdist
- name: Upload sdist artifact to GitHub Actions storage
uses: actions/upload-artifact@v4
with:
name: sdist
path: apis/python/dist/
test_sdist:
name: Build source distribution
needs: build_sdist
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15]
python_version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist
path: apis/python/dist/
- name: Install older version of numba to prevent building from source on osx-64 (no wheels for numba 0.63+)
if: ${{ matrix.os == 'macos-15-intel' }}
run: pip install numba==0.60.0
- name: Install sdist artifact
working-directory: apis/python
run: |
echo $PWD
pip install --verbose dist/*.tar.gz
- name: sdist smoke test ${{ matrix.os }}
run: python -c 'import tiledbsoma; print(tiledbsoma.pytiledbsoma.__file__); tiledbsoma.show_package_versions()'
build_wheels:
name: ${{ matrix.python_name }}-${{ matrix.platform }} wheel
runs-on: ${{ matrix.os }}
strategy:
matrix:
python_name: ['cp39', 'cp310', 'cp311', 'cp312', 'cp313']
os: [ubuntu-22.04, ubuntu-22.04-arm, macos-15-intel, macos-15]
include:
- platform: manylinux_x86_64
os: ubuntu-22.04
- platform: manylinux_aarch64
os: ubuntu-22.04-arm
- platform: macosx_x86_64
os: macos-15-intel
- platform: macosx_arm64
os: macos-15
steps:
- name: Checkout TileDB-SOMA
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch tags: https://github.com/actions/checkout/issues/2199
fetch-tags: true # Tags needed for python API version number
- name: "Setup for macOS"
if: ${{ startsWith(matrix.os, 'macos-') == true }}
run: |
set -e pipefail
brew update
brew install automake llvm
- name: "Setup for arm builds"
if: ${{ endsWith(matrix.platform, 'aarch64') == true }}
run: |
echo "CIBW_BEFORE_BUILD_LINUX=dnf install -y ninja-build perl-IPC-Cmd zip" >> $GITHUB_ENV
echo ${{ env.CIBW_BEFORE_BUILD_LINUX }}
- name: Get arch
if: ${{ startsWith(matrix.os, 'macos-') == true }}
run: |
plat="${{ matrix.platform }}"
arch="${plat#*_}"
echo "ARCH=$arch" >> $GITHUB_ENV
- name: Install dependencies
run: |
pip install --upgrade 'setuptools>=70.1' importlib-metadata # cf. https://github.com/single-cell-data/TileDB-SOMA/pull/3076
pip list
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.1
with:
package-dir: apis/python/
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ matrix.python_name }}-${{ matrix.platform }}
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_BUILD_LINUX: ${{ env.CIBW_BEFORE_BUILD_LINUX || '' }}
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux_2_28"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CMAKE_OSX_ARCHITECTURES: ${{ env.arch || ''}}
MACOSX_DEPLOYMENT_TARGET: "13.3"
- name: Check wheel name
run: ls -l ./wheelhouse/*.whl
- name: Upload wheel-${{ matrix.python_name }}-${{ matrix.platform }}
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python_name }}-${{ matrix.platform }}
path: ./wheelhouse/*.whl
test_wheels:
name: "Smoke test ${{ matrix.python_version}}-${{ matrix.platform }} wheel"
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-22.04, ubuntu-22.04-arm, macos-15-intel, macos-15]
include:
- platform: manylinux_x86_64
os: ubuntu-22.04
- platform: manylinux_aarch64
os: ubuntu-22.04-arm
- platform: macosx_x86_64
os: macos-15-intel
- platform: macosx_arm64
os: macos-15
- wheel_suffix: manylinux_2_28_x86_64
os: ubuntu-22.04
- wheel_suffix: manylinux_2_28_aarch64
os: ubuntu-22.04-arm
- wheel_suffix: macosx_13_0_x86_64
os: macos-15-intel
- wheel_suffix: macosx_13_0_arm64
os: macos-15
- python_name: "cp39"
python_version: "3.9"
- python_name: "cp310"
python_version: "3.10"
- python_name: "cp311"
python_version: "3.11"
- python_name: "cp312"
python_version: "3.12"
- python_name: "cp313"
python_version: "3.13"
exclude:
- os: macos-15-intel
python_version: 3.13
fail-fast: false
steps:
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: wheel-${{ matrix.python_name }}-${{ matrix.platform }}
- name: Install numba to prevent building from source
if: ${{ matrix.os == 'macos-15-intel' }}
run: pip install numba==0.60.0
- name: Install wheel
run: |
set -x
ls -lR
WHL=$(find . -name 'tiledbsoma-*-${{ matrix.python_name }}-${{ matrix.python_name }}-*${{ matrix.wheel_suffix }}.whl')
echo "WHL=$WHL"
if [ -z "$WHL" ]; then echo "No wheel found"; exit 1; fi
unzip -l $WHL
pip install wheel
pip install $WHL
echo "WHL=$WHL" >> $GITHUB_ENV
- name: Smoke test ${{ matrix.os }}
run: python -c 'import tiledbsoma; print(tiledbsoma.pytiledbsoma.__file__); tiledbsoma.show_package_versions()'
- name: Smoke test in docker
if: ${{ matrix.os == 'ubuntu-24.04' }}
run: |
docker run -v $(pwd):/mnt python:${{ matrix.python_version[0] }} bash -ec "
apt-get -qq update && apt-get install -y python3-pip python3-wheel
pip3 install /mnt/$WHL
python3 -c 'import tiledbsoma; print(tiledbsoma.pytiledbsoma.__file__); tiledbsoma.show_package_versions()'
"
# Publish to TestPyPI upon user workflow request
publish_test_pypi:
name: Publish package to TestPyPI
needs: [test_sdist, test_wheels]
runs-on: ubuntu-24.04
environment: test-pypi
permissions:
id-token: write
if: github.event_name == 'workflow_dispatch'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create dist
run: |
set -x
mkdir dist
cp sdist/tiledbsoma-*.tar.gz wheel-*/*.whl dist
ls -l dist
- name: Publish packages to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages_dir: dist
verbose: true
# Publish to PyPI upon release.
publish_pypi:
name: Publish package to PyPI
needs: [test_sdist, test_wheels]
runs-on: ubuntu-24.04
# Configuration: https://github.com/single-cell-data/SOMA/settings/environments
environment: pypi
# Configuration: https://pypi.org/manage/project/somacore/settings/publishing
permissions:
id-token: write
if: github.event_name == 'release'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create dist
run: |
set -x
mkdir dist
cp sdist/tiledbsoma-*.tar.gz wheel-*/*.whl dist
ls -l dist
- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: dist
verbose: true
# File a bug report if anything fails, but don't file tickets for manual runs
# -- only for scheduled ones.
create_issue_on_fail:
runs-on: ubuntu-24.04
needs: [test_sdist, test_wheels, publish_test_pypi, publish_pypi]
if: (failure() || cancelled()) && github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request' && github.run_attempt == 1
steps:
- name: Checkout TileDB-SOMA `main`
uses: actions/checkout@v4
- name: Create Issue if Build Fails
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/workflows/failed-issue-template.md
assignees: jp-dark, aaronwolen
update_existing: true