Skip to content

[pre-commit.ci] pre-commit autoupdate #166

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #166

name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
types: [published]
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build_wheels:
name: Build wheels (${{ matrix.python.version }}) on ${{ matrix.platform.os }}/${{ matrix.platform.arch }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-20.04
arch: x86_64
fflags: -march=x86-64 -mavx
- os: macos-11
arch: x86_64
fflags: -march=x86-64 -mavx
- os: macos-12
arch: arm64
fflags: -march=armv8.5-a
python:
- version: "3.8"
cp: cp38
- version: "3.9"
cp: cp39
- version: "3.10"
cp: cp310
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
- name: Setup gfortran
if: ${{ startsWith(matrix.platform.os, 'macos') }}
run: |
case ${{ matrix.platform.os }} in
macos-11)
wget -nv https://github.com/fxcoudert/gfortran-for-macOS/releases/download/11.2-bigsur-intel/gfortran-Intel-11.2-BigSur.dmg
;;
macos-12)
wget -nv https://github.com/fxcoudert/gfortran-for-macOS/releases/download/12.1-monterey/gfortran-Intel-12.1-Monterey.dmg
;;
*)
echo "Invalid platform:" ${{ matrix.platform.os }}
exit 1
esac
sudo hdiutil attach gfortran*.dmg
sudo installer -package /Volumes/gfortran*/gfortran*/gfortran*.pkg -target /
- name: Checking gfortran
run: gfortran --version
- name: Build wheels
if: ${{ matrix.platform.arch != 'arm64' }}
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python.cp }}-*
CIBW_BUILD_VERBOSITY: 3
CIBW_ENVIRONMENT: FFLAGS='${{ matrix.platform.fflags }}'
CIBW_SKIP: "*-musllinux_*"
CIBW_ARCHS: ${{ matrix.platform.arch }}
CIBW_BEFORE_TEST_LINUX: |
yum install -y openmpi-devel environment-modules
source /usr/share/Modules/init/sh
module load mpi
pip install mpi4py
CIBW_BEFORE_TEST_MACOS: brew install openmpi
CIBW_TEST_EXTRAS: dev
CIBW_TEST_COMMAND: |
if [[ ${{ matrix.platform.os }} == ubuntu-20.04 ]]; then
source /usr/share/Modules/init/sh
module load mpi
fi
mpirun -np 6 --oversubscribe --allow-run-as-root pytest -m mpi --no-cov {package}/tests
pytest {package}/tests
PYTHONFAULTHANDLER: "1"
- name: Build macosx_arm64
# This is solely used to build macosx_arm64. As soon as Github Actions make
# MacOS arm64 runners available, it should be removed. Adapted from scipy's CI.
if: ${{ matrix.platform.os == 'macos-12' && matrix.platform.arch == 'arm64' }}
run: |
set -ex
# Update license
cat tools/wheels/LICENSE_osx.txt >> LICENSE.txt
export PLAT="arm64"
export _PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
export CROSS_COMPILE=1
# Need macOS >= 11 for arm compilation.
export MACOSX_DEPLOYMENT_TARGET=11.0
# SDK root needs to be set early, installation of gfortran/openblas
# needs to go in the correct location.
export SDKROOT=/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk
export ARCHFLAGS=" -arch arm64 "
source tools/wheels/gfortran_utils.sh
export MACOSX_DEPLOYMENT_TARGET=11.0
# The install script requires the PLAT variable in order to set
# the FC variable
export PLAT=arm64
install_arm64_cross_gfortran
export FC=$FC_ARM64
export PATH=$FC_LOC:$PATH
export FFLAGS=" -arch arm64 $FFLAGS"
export LDFLAGS=" $FC_ARM64_LDFLAGS $LDFLAGS -L/opt/arm64-builds/lib -arch arm64"
sudo ln -s $FC $FC_LOC/gfortran
echo $(type -p gfortran)
# having a test fortran program has helped in debugging problems with the
# compiler environment.
$FC $FFLAGS tools/wheels/test.f $LDFLAGS
ls -al *.out
otool -L a.out
export PKG_CONFIG_PATH=/opt/arm64-builds/lib/pkgconfig
export PKG_CONFIG=/usr/local/bin/pkg-config
export CFLAGS=" -arch arm64 $CFLAGS"
export CXXFLAGS=" -arch arm64 $CXXFLAGS"
export LD_LIBRARY_PATH="/opt/arm64-builds/lib:$FC_LIBDIR:$LD_LIBRARY_PATH"
# install dependencies for the build machine
pipx run build --wheel
# Enables delocate to find the libopenblas/libgfortran libraries.
export DYLD_LIBRARY_PATH=/opt/gfortran-darwin-arm64/lib/gcc/arm64-apple-darwin20.0.0/10.2.1:/opt/arm64-builds/lib
pip3 install delocate
delocate-listdeps dist/pysimulators*.whl
delocate-wheel --require-archs=arm64 -k -w wheelhouse dist/pysimulators*.whl
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
upload_all:
needs: [build_sdist, build_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}