-
Notifications
You must be signed in to change notification settings - Fork 3
178 lines (155 loc) · 5.86 KB
/
build-test-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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 }}