Skip to content

Workflow file for this run

# adapted from:
# - https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
# - https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/wheels.yml
# - https://github.com/scikit-image/scikit-image/blob/main/.github/workflows/wheels_recipe.yml
name: Build and upload to PyPI
on:
push:
branches:
- wheels
release:
types:
- published
jobs:
build_wheels_mac:
name: Build ${{ matrix.py }}-${{ matrix.cibw_arch }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# os: [macos-13, macos-14]
os: [macos-13]
# os: [macos-14]
py: [cp36, cp37, cp38, cp39, cp310, cp311, cp312]
cibw_arch: [x86_64, arm64]
include:
- cibw_test_requires: 'pytest tensorflow'
# - os: macos-13
# cibw_arch: x86_64
# - os: macos-14
# cibw_arch: arm64
exclude:
- py: cp36
cibw_arch: arm64
- py: cp37
cibw_arch: arm64
# - os: macos-14
# py: cp36
# - os: macos-14
# py: cp37
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Install conda
shell: bash
run: |
set -ex
MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-$(uname -m).sh"
MINIFORGE_PATH="$HOME/miniforge"
curl -L --retry 10 $MINIFORGE_URL -o ./miniforge.sh
bash ./miniforge.sh -b -p $MINIFORGE_PATH
echo "CONDA_HOME=$MINIFORGE_PATH" >> $GITHUB_ENV
- name: Build wheels for CPython (macOS)
run: |
if [[ "$CIBW_ARCHS_MACOS" == "arm64" ]]; then
# SciPy requires 12.0 on arm to prevent kernel panics
# https://github.com/scipy/scipy/issues/14688
export MACOSX_DEPLOYMENT_TARGET=12.0
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2"
else
export MACOSX_DEPLOYMENT_TARGET=10.9
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2"
fi
echo MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
# use conda to install llvm-openmp and use it for building
sudo "$CONDA_HOME/bin/conda" create -n build $OPENMP_URL
PREFIX="$CONDA_HOME/envs/build"
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"
python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: "${{ matrix.py }}-*"
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: "${{ matrix.cibw_test_requires }}"
CIBW_TEST_COMMAND: pytest -v -m "not gpu" {project}
# CIBW_TEST_SKIP: "*cp36*-macosx*" # Python crashes ¯\_(ツ)_/¯
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*.whl
# build_wheels:
# name: Build ${{ matrix.py }} wheels on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-latest, windows-latest]
# py: [cp36, cp37, cp38, cp39, cp310, cp311, cp312]
# include:
# - cibw_test_requires: 'pytest tensorflow'
# - os: ubuntu-latest
# py: cp37
# cibw_test_requires: 'pytest tensorflow urllib3<2' # ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Install Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.x'
# - name: Install cibuildwheel
# run: python -m pip install cibuildwheel
# - name: Check if conda is installed
# shell: bash
# run: |
# command -v conda && ret=$? || ret=$?
# echo "CONDA_INSTALLED=$ret" >> $GITHUB_ENV
# - name: Build wheels for CPython (Linux and Windows)
# if: startsWith(matrix.os, 'macos') == false
# run: |
# python -m cibuildwheel --output-dir dist
# env:
# # only build for platforms where tensorflow is available
# CIBW_BUILD: "${{ matrix.py }}-*{x86_64,win_amd64}"
# CIBW_SKIP: "*musllinux*"
# # numba is a requirement and only has wheels for manylinux2014
# CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# CIBW_BUILD_VERBOSITY: 1
# CIBW_TEST_REQUIRES: "${{ matrix.cibw_test_requires }}"
# CIBW_TEST_COMMAND: pytest -v -m "not gpu" {project}
# # CIBW_TEST_SKIP: "*musllinux*"
# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: dist
# path: ./dist/*.whl
# build_sdist:
# name: Build source distribution
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Build sdist
# run: pipx run build --sdist
# - name: Upload sdist
# uses: actions/upload-artifact@v3
# with:
# name: dist
# path: dist/*.tar.gz
# upload_pypi:
# name: Upload to PyPI
# needs: [build_wheels, build_wheels_mac, build_sdist]
# runs-on: ubuntu-latest
# if: github.event_name == 'release' && github.event.action == 'published'
# steps:
# - name: Download wheels and sdist
# uses: actions/download-artifact@v3
# with:
# name: dist
# path: dist
# - name: Check that package version matches git tag ${{ github.ref_name }}
# shell: bash
# run: |
# ls -l dist
# test -f "dist/stardist-${{ github.ref_name }}.tar.gz"
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
# verbose: true
# # password: ${{ secrets.TESTPYPI_API_TOKEN }}
# # repository-url: https://test.pypi.org/legacy/