Skip to content

Debug MacOS…

Debug MacOS… #682

Workflow file for this run

name: build
on:
push:
pull_request:
jobs:
# Quickly check with flake8 without having to go through the whole build:
flake8:
name: "Fast flake8"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Check on lowest supported python version to catch syntax errors:
- uses: actions/setup-python@v5
with: { python-version: "3.7" }
- run: pip install flake8
- run: flake8
build_macos:
name: "Build: MacOS"
runs-on: macos-13
strategy:
matrix:
arch:
- x86_64
- arm64
steps:
- uses: actions/checkout@v4
- run: echo "MADX_VERSION=$(cat MADX_VERSION)" >> $GITHUB_ENV
- name: Download cached MAD-X build
id: madx-build-cache
uses: actions/cache@v4
with:
path: src/MAD-X/dist
key: "\
madx-${{ env.MADX_VERSION }}-\
macos-${{ matrix.arch }}-\
patches-${{ hashFiles('.github/patch/*') }}-\
scripts-${{ hashFiles('.github/build/macos/madx*') }}\
"
- run: git clone https://github.com/MethodicalAcceleratorDesign/MAD-X
src/MAD-X -b $MADX_VERSION --depth 1
if: steps.madx-build-cache.outputs.cache-hit != 'true'
# Select matching Xcode and SDK, see: https://xcodereleases.com/
- run: |
sudo xcode-select -switch /Applications/Xcode_15.2.app
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
- name: Setup gfortran
run: |
set -xeo pipefail
if [[ ${{ matrix.arch }} == "x86_64" ]]; then
FC=gfortran-12
LIBDIR=$(dirname $(find /usr/local/Cellar/gcc@12 -name libgfortran.dylib))
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
elif [[ ${{ matrix.arch }} == "arm64" ]]; then
# See: https://github.com/MacPython/gfortran-install
name=gfortran-darwin-arm64-cross
curl -L -O https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/${name}.tar.gz
sudo tar -f ${name}.tar.gz -C /opt -xzv
rm ${name}.tar.gz
FC=$(find /opt/${name}/bin -name "*-gfortran")
LIBDIR=$(dirname $(find /opt/${name}/lib -name libgfortran.dylib))
# See: https://github.com/pypa/cibuildwheel/discussions/997
echo "ARCHFLAGS=-arch arm64" >> $GITHUB_ENV
echo "_PYTHON_HOST_PLATFORM=macosx-11.0-arm64" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
fi
LDFLAGS="-L$LIBDIR -Wl,-rpath,$LIBDIR"
echo "FC=$FC" >> $GITHUB_ENV # for cmake
echo "LDFLAGS=$LDFLAGS" >> $GITHUB_ENV # for setuptools
echo "LIBDIR=$LIBDIR" >> $GITHUB_ENV # for delocate step
- name: Build MAD-X
if: steps.madx-build-cache.outputs.cache-hit != 'true'
run: .github/build/macos/madx.sh src/MAD-X ${{ matrix.arch }}
- uses: actions/setup-python@v5
with: { python-version: "3.6" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.7" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.8" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.9" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.10" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.11" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- uses: actions/setup-python@v5
with: { python-version: "3.13" }
- run: .github/build/macos/cpymad.sh src/MAD-X/dist || true
- name: Fixup wheel dependencies
run: |
pip3 install delocate
DYLD_LIBRARY_PATH=$LIBDIR delocate-wheel dist/*.whl
DYLD_LIBRARY_PATH=$LIBDIR delocate-listdeps --all dist/*.whl
- name: Upload cpymad wheels
uses: actions/upload-artifact@v4
with:
name: dist-macos-${{ matrix.arch }}
path: dist
- uses: mxschmitt/action-tmate@v3
with: {limit-access-to-actor: true}
if: failure()
test:
name: Tests
runs-on: ${{ matrix.os.run }}
needs: [build_macos]
strategy:
matrix:
os:
- {run: macos-latest, dist: dist-macos-arm64}
- {run: macos-13, dist: dist-macos-x86_64}
python:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
exclude:
- os: {run: macos-latest}
python: '3.7'
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Download cpymad wheels
uses: actions/download-artifact@v4
with:
name: ${{ matrix.os.dist }}
path: dist
- name: Install cpymad from wheel
run: |
set -ex
python -m pip install -U pip || sudo python -m pip install -U pip
pip install cpymad -f dist --no-index --no-deps
pip install cpymad
- run: pip install flake8 twine coverage coveralls pytest
- run: twine check dist/*
- run: flake8
- run: coverage run --source=cpymad -p -m pytest -v -k "not dframe"
- run: pip install pandas
- run: coverage run --source=cpymad -p -m pytest -v -k "dframe"