Skip to content

BUILD(cfg): Add build toolchain for CUDA variant #270

BUILD(cfg): Add build toolchain for CUDA variant

BUILD(cfg): Add build toolchain for CUDA variant #270

Workflow file for this run

# Provide continuous delivery (CD).
#
# CD deliverables currently include:
# - source distributions (for PyPI);
# - (natively) built Python wheel distributions (for PyPI);
# - (natively) built Conda packages (for Anaconda).
#
name: continuous-delivery
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.post[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
paths:
- deploy/pkg/conda_recipe/**
- .github/workflows/cd.yml
workflow_dispatch:
inputs:
run_build_sdist:
description: 'Run job build_sdist'
type: boolean
default: false
required: false
run_build_bdist:
description: 'Run job build_bdist'
type: boolean
default: false
required: false
run_build_conda:
description: 'Run job build_conda'
type: boolean
default: false
required: false
version_tag:
description: 'Version tag for delivery'
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_sdist:
name: Build sdist tarball
runs-on: ubuntu-latest
timeout-minutes: 20
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_sdist == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install packaging requirements
run: python -m pip install --upgrade build twine
- name: Copy Python project configuration file
run: cp .pyproject.toml pyproject.toml
- name: Build source distribution
run: python -m build --sdist --outdir dist/ .
- name: Verify source distribution
run: python -m twine check --strict dist/*
- name: Save tarball to sdist
uses: actions/upload-artifact@v4
with:
name: sdist_tar_gz_${{ github.ref_name }}
path: dist/*.tar.gz
- name: Save tarball to pypi_dist
uses: actions/upload-artifact@v4
with:
name: pypi_dist_${{ github.ref_name }}
path: dist/*.tar.gz
build_bdist:
name: Build bdist wheel
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
# Allow manual trigger from inputs.
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_bdist == 'true'
steps:
# HACK: GitHub macOS runner image version (for deployment target).
- name: Extract runner image version (macOS only)
if: runner.os == 'macOS'
run: >-
echo "IMAGE_VERSION=$(sw_vers --productVersion | cut -d '.' -f 1).0"
>> "${GITHUB_ENV}"
# HACK: GitHub macOS runner defaults to a broken release of Xcode.
# See https://github.com/actions/runner-images/issues/9273.
- name: Pin Xcode version (macOS only)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install packaging requirements
run: python -m pip install --upgrade twine
- name: Install (pre-)compiled dependencies (macOS only)
if: runner.os == 'macOS'
run: |
bash deploy/pkg/buildwheel_deps_macos.sh
if [[ $(uname -m) == 'arm64' ]]; then
echo "MACOSX_VERS_MIN=11.0" >> "${GITHUB_ENV}"
elif [[ $(uname -m) == 'x86_64' ]]; then
echo "MACOSX_VERS_MIN=10.15" >> "${GITHUB_ENV}"
fi
- name: Copy Python project configuration file
run: cp .pyproject.toml pyproject.toml
- name: Build built distribution
uses: pypa/cibuildwheel@v2.20.0
with:
package-dir: .
output-dir: dist/
config-file: pyproject.toml
env:
# # Default to GCC compiler and OpenMP on macOS.
# # HACK: Hardcode g++ compiler choice on recent GitHub macOS
# # runners owing to unusual Homebrew paths. In the CIBW workflow,
# # Homebrew 'fftw' formula installs g++-14 as a dependency which
# # conflicts with the runner image.
# CIBW_ENVIRONMENT_MACOS: >-
# PY_CXX=$(brew --prefix)/bin/g++-14
# PY_CXXFLAGS=-I$(brew --prefix)/include
# PY_LDFLAGS=-L$(brew --prefix)/lib
# PY_OMP=1
# # Switch to LLVM compiler and OpenMP on macOS.
# CIBW_ENVIRONMENT_MACOS: >-
# PY_CXX=$(brew --prefix llvm@15)/bin/clang++
# PY_CXXFLAGS=-I$(brew --prefix)/include
# PY_LDFLAGS=-L$(brew --prefix)/lib
# PY_OMP=1
# PY_CXXFLAGS_OMP="-I$(brew --prefix libomp)/include -fopenmp"
# PY_LDFLAGS_OMP="-L$(brew --prefix libomp)/lib -lomp"
# HACK: Hardcode macOS deployment target to align with the
# GitHub runner image version. In the CIBW workflow,
# Homebrew-installed libraries and `delocate-wheel` enforce this.
# MACOSX_DEPLOYMENT_TARGET: ${{ env.IMAGE_VERSION }}
# SYSTEM_VERSION_COMPAT: '0'
MACOSX_DEPLOYMENT_TARGET: ${{ env.MACOSX_VERS_MIN }}
SYSTEM_VERSION_COMPAT: '0'
CIBW_ENVIRONMENT_MACOS: >-
PY_CXX=clang++
PY_CXXFLAGS=-Itmp/deps/include
PY_LDFLAGS=-Ltmp/deps/lib
PY_OMP=1
PY_CXXFLAGS_OMP="-Xpreprocessor -fopenmp"
PY_LDFLAGS_OMP="-Xpreprocessor -fopenmp"
PY_BUILD_PARALLEL='-j'
MACOSX_DEPLOYMENT_TARGET=${{ env.MACOSX_VERS_MIN }}
SYSTEM_VERSION_COMPAT=0
CIBW_BEFORE_ALL_MACOS:
- name: Verify built distribution
run: python -m twine check --strict dist/*
- name: Save wheel to bdist
uses: actions/upload-artifact@v4
with:
name: bdist_whl_${{ matrix.os }}_${{ github.ref_name }}
path: dist/*.whl
- name: Save wheel to pypi_dist
uses: actions/upload-artifact@v4
with:
name: pypi_dist_${{ runner.os }}_${{ runner.arch }}_${{ github.ref_name }}
path: dist/*.whl
build_conda:
name: Build Conda package
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_conda == 'true'
defaults:
run:
shell: bash -el {0}
steps:
# HACK: GitHub macOS runner defaults to a broken release of Xcode.
# See https://github.com/actions/runner-images/issues/9273.
- name: Pin Xcode version (macOS only)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up (Mini)conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: conda_bld
channels: conda-forge
channel-priority: strict
- name: Install packaging requirements
run: |
conda install -y conda-build conda-verify conda-package-handling
# `cph` not found otherwise.
conda_root=$(conda config --show root_prefix | sed 's/root_prefix: //')
conda_env=${conda_root}/envs/conda_bld
export PATH="$PATH:${conda_root}/bin:${conda_env}/bin"
- name: Override version
if: github.event_name == 'workflow_dispatch'
uses: knicknic/os-specific-run@v1.0.4
env:
recipe_file: deploy/pkg/conda_recipe/meta.yaml
with:
linux: |
vers_tag=${{ github.event.inputs.version_tag }}
if [[ ! -z ${vers_tag} ]]; then
sed -i "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
fi
macos: |
vers_tag=${{ github.event.inputs.version_tag }}
if [[ ! -z ${vers_tag} ]]; then
sed -i '' "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
fi
- name: Build Conda package
env:
recipe_dir: deploy/pkg/conda_recipe
output_dir: dist/
variants: "{'python': ['3.10', '3.11', '3.12']}"
run: |
# Create output directory if non-existent.
if [[ ! -d ${output_dir} ]]; then mkdir -p ${output_dir}; fi
# Build.
conda build --strict-verify --no-anaconda-upload ${recipe_dir} \
--variants "${variants}" --output-folder ${output_dir}
# Transmute.
find ${output_dir} -name '*.tar.bz2' \
-exec cph transmute {} .conda --out-folder ${output_dir} \;
- name: Save build to conda_bld
uses: actions/upload-artifact@v4
with:
name: conda_bld_${{ matrix.os }}_${{ github.ref_name }}
path: dist/*
- name: Save build to conda_dist
uses: actions/upload-artifact@v4
with:
name: conda_dist_${{ runner.os }}_${{ runner.arch }}_${{ github.ref_name }}
path: |
dist/**/*.tar.bz2
dist/*.conda