Skip to content

CI: test only macos builds - more diag for py38 issue #36

CI: test only macos builds - more diag for py38 issue

CI: test only macos builds - more diag for py38 issue #36

Workflow file for this run

name: PyPI Publish
on:
release:
types: [published]
push:
pull_request:
workflow_dispatch:
jobs:
build-wheels:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
name: ${{ matrix.host-os }} / OpenMP ${{ matrix.openmp }}
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
# host-os: ["ubuntu-latest", "windows-latest", "macos-13", "macos-14"]
# host-os: ["ubuntu-latest", "macos-13", "macos-14"]
host-os: ["macos-14"]
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
openmp: ["off"]
fail-fast: false
env:
CIBW_SKIP: pp* cp36-* cp37-* cp*_i686 cp*-musllinux_*
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Set OpenMP mode
if: matrix.openmp == 'on'
run: |
export MODE="omp"
echo "MODE=${MODE}" >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: "env/python"
- uses: actions/upload-artifact@v4
with:
name: srwpy-wheels-${{ matrix.host-os }}
path: ./wheelhouse/*.whl
- name: Check built libs
if: runner.os == 'macOS'
run: |
set -vxeuo pipefail
cd wheelhouse/
unzip srwpy-4.1.0-cp38-cp38-*.whl
whl=srwpy/srwlpy.so
file $whl
otool -L $whl
# TODO: add sdist generation/uploading step
# - name: Set MacOS Deployment Target
# if: runner.os == 'macOS'
# run: |
# export MACOSX_DEPLOYMENT_TARGET="10.15"
# echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
# - uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: testenv
# allow-softlinks: true
# auto-activate-base: false
# auto-update-conda: true
# channel-priority: flexible
# channels: conda-forge
# miniconda-version: "latest"
# python-version: "3.10"
# show-channel-urls: true
# use-only-tar-bz2: false
# - name: Set up Visual Studio shell
# if: runner.os == 'Windows'
# uses: egor-tensin/vs-shell@v2
# with:
# arch: x64
# - name: Install build requirements with conda
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# conda install -y cmake
# - name: Install OpenMP for macOS with conda
# if: runner.os == 'macOS' && matrix.openmp == 'on'
# run: |
# set -vxeuo pipefail
# conda install -y -c conda-forge llvm-openmp
# # NOTE: This step is not needed for fast tests.
# # - name: Install mpi4py for Unix with conda
# # if: runner.os != 'Windows'
# # run: |
# # set -vxeuo pipefail
# # conda install -y -c conda-forge mpi4py openmpi
# - name: Install cibuildwheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -m pip install --upgrade pip
# python -m pip install cibuildwheel
# echo "CIBW_BEFORE_ALL=pip install cmake" >> $GITHUB_ENV
# PYTH_VER=${{ matrix.python-version }}
# PYTH_VER=${PYTH_VER//.}
# echo "CIBW_BUILD="cp$PYTH_VER-manylinux*"" >> $GITHUB_ENV
# - name: Build wheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -VV
# python -m cibuildwheel --output-dir dist env/python
# ls -la dist/*
# - name: Build wheel on Windows/Mac
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# cd env/python
# python -VV
# python setup.py bdist_wheel
# ls -la dist/*
# mkdir -p ../../dist
# cp dist/*.whl ../../dist/
# - name: Publish wheels to GitHub artifacts
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist/*
test-wheels:
needs: build-wheels
name: ${{ matrix.host-os }} / Python ${{ matrix.python-version }}
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
# host-os: ["ubuntu-latest", "windows-latest", "macos-13", "macos-14"]
host-os: ["ubuntu-latest", "macos-13", "macos-14"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Set environment variables
run: |
export PYTHONVER=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
echo "PYTHONVER=${PYTHONVER}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: test-env
create-args: >-
python=${{ matrix.python-version }}
# NOTE: this does not properly make the installed python version active, so fails on MacOS runners.
# - name: Install Python
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: srwpy-wheels-${{ matrix.host-os }}
path: wheelhouse
- name: Display structure of downloaded files
run: ls -laR wheelhouse/
- name: Install the package and test requirements
run: |
set -vxeuo pipefail
which python
python -VV
python -m pip install -v wheelhouse/*-cp${PYTHONVER}-*.whl
# Smoke import test:
python -c "import srwpy; import srwpy.srwlpy"
# Check CLI tools:
srw-viewer --help
python -m pip install -r env/python/requirements-dev.txt
python -m pip list
- name: Run fast tests
run: |
set -vxeuo pipefail
cd env/python
pytest -k fast
publish-to-pypi:
# Hints from:
# - https://github.com/pypa/gh-action-pypi-publish/discussions/28
# - https://github.com/Lightning-AI/lightning/blob/master/.github/workflows/release-pypi.yml
if: github.event_name == 'release'
name: Publish to PyPI
needs: test-wheels
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Download wheels from GitHub artifacts
uses: actions/download-artifact@v3
with:
name: wheels
path: dist/
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/