-
Notifications
You must be signed in to change notification settings - Fork 12
271 lines (242 loc) · 9.27 KB
/
build.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: build
on:
push:
branches: [ master ]
tags:
- v*
- p*
pull_request:
branches: [ master ]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
build:
name: ${{ matrix.python }} ${{ matrix.os }} ${{ matrix.plat }} ${{ matrix.parallel }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-12 ]
python: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
manylinux: [ 2014 ]
plat: [ x86_64, arm64 ]
parallel: [ serial ]
exclude:
- os: ubuntu-latest
plat: arm64
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: install requirements
env:
MKLROOT: ~/.local
run: |
export PYT=$(which python)
python -m pip install pip build twine setuptools pytest --upgrade
python -m pip install mkl==2021.4 mkl-include intel-openmp numpy psutil 'cmake>=3.19' pybind11==2.12.0
- name: install requirements (linux / mpi)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install libopenmpi-dev
python -m pip install mpi4py
- name: fix mkl for amd cpu
if: matrix.os == 'ubuntu-latest'
run: |
lscpu
export CPUTYPE=$(lscpu | grep 'Vendor ID' | awk '{print $3}')
echo $CPUTYPE
if [ "$CPUTYPE" = "AuthenticAMD" ]; then
echo "int mkl_serv_intel_cpu_true() { return 1; }" > fixcpu.c
gcc -shared -fPIC -o libfixcpu.so fixcpu.c
fi
getconf LONG_BIT
- name: build test
env:
MKLROOT: ~/.local
run: |
mkdir build
cd build
cmake .. -DUSE_MKL=ON
make -j 4
cd ..
echo "PYTHONPATH=./build:${PYTHONPATH}" >> $GITHUB_ENV
- name: run test (serial, linux)
if: matrix.os == 'ubuntu-latest'
env:
MKLROOT: ~/.local
run: |
export CPUTYPE=$(lscpu | grep 'Vendor ID' | awk '{print $3}')
if [ "$CPUTYPE" = "AuthenticAMD" ]; then
export LD_PRELOAD=$PWD/libfixcpu.so
fi
py.test pyblock3/algebra
py.test pyblock3/algorithms --ignore=pyblock3/algorithms/tests/test_soc.py
- name: run test (serial, macos)
if: matrix.os == 'macos-12'
env:
MKLROOT: ~/.local
run: |
py.test pyblock3/algebra
py.test pyblock3/algorithms --ignore=pyblock3/algorithms/tests/test_soc.py
- name: build wheels (macos-x86_64)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-12' && matrix.plat == 'x86_64'
env:
TAG_STRING: ${{ github.event.ref }}
MACOSX_DEPLOYMENT_TARGET: '10.9'
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
brew update
brew install libomp
cp /usr/local/opt/libomp/include/*.h /usr/local/include/
brew install gnu-sed
export PATH=/usr/local/opt/gnu-sed/bin:$PATH
echo ${TAG_STRING:11}
gsed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py
# if use mkl, will need iomp5
gsed -i "/DUSE_MKL/a \ '-DOMP_LIB=OMP'," setup.py
gsed -i "/mkl/d" setup.py
gsed -i "/intel-openmp/d" setup.py
gsed -i "/DUSE_MKL/c \ '-DUSE_MKL=OFF'," setup.py
export OMPROOT=$(brew --prefix libomp)
echo ${OMPROOT}
cmake --version
python -m pip install wheel delocate==0.10.7
python -m pip wheel . -w ./dist --no-deps
export DYLD_LIBRARY_PATH=$(python -c "import site;print(':'.join(x+'/../..' for x in site.getsitepackages()))")
# prevent delocating libomp
export DELO_PY=$(cat $(which delocate-wheel) | head -1 | awk -F'!' '{print $2}')
export DELO_DE=$(${DELO_PY} -c "from delocate import delocating;print(delocating.__file__)")
gsed -i '/r_ed_base = base/a \ if "libomp" in required: needs_delocating.add(required); continue' ${DELO_DE}
gsed -i '/new_install_name =/a \ if "libomp" in required: new_install_name = "/usr/local/opt/libomp/lib/libomp.dylib"' ${DELO_DE}
delocate-wheel -k dist/*.whl
- name: build wheels (macos-arm64)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-12' && matrix.plat == 'arm64'
env:
TAG_STRING: ${{ github.event.ref }}
MACOSX_DEPLOYMENT_TARGET: '11.0'
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
brew update
brew install libomp
cp /usr/local/opt/libomp/include/*.h /usr/local/include/
brew install gnu-sed
export PATH=/usr/local/opt/gnu-sed/bin:$PATH
echo ${TAG_STRING:11}
gsed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py
gsed -i "/DUSE_MKL/a \ '-DOMP_LIB=OMP'," setup.py
gsed -i "/DUSE_MKL/a \ '-DARCH_ARM64=ON'," setup.py
gsed -i "/mkl/d" setup.py
gsed -i "/intel-openmp/d" setup.py
gsed -i "/DUSE_MKL/c \ '-DUSE_MKL=OFF'," setup.py
git clone https://github.com/Homebrew/brew arm-brew
cd arm-brew && git checkout 3.6.16 && cd ..
./arm-brew/bin/brew update
OMPGZ=$(./arm-brew/bin/brew fetch --force --bottle-tag=arm64_monterey libomp | grep "Downloaded to" | awk '{print $3}')
./arm-brew/bin/brew install ${OMPGZ}
export OMPROOT=$(./arm-brew/bin/brew --prefix libomp)
echo ${OMPROOT}
cmake --version
python -m pip install wheel delocate==0.10.7
export _PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
export SDKROOT=/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk
export CROSS_COMPILE=1
export PLAT="arm64"
python -m pip wheel . -w ./dist --no-deps
delocate-wheel --require-archs=arm64 -k dist/*.whl
- name: prepare build wheels (manylinux)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
env:
TAG_STRING: ${{ github.event.ref }}
run: |
echo ${TAG_STRING:11}
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py
cp ./.github/actions/build-wheel/Dockerfile.manylinux${{ matrix.manylinux }} ./.github/actions/build-wheel/Dockerfile
- name: build wheels (manylinux)
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
uses: ./.github/actions/build-wheel
with:
python-version: ${{ matrix.python }}
parallel: ${{ matrix.parallel }}
- name: release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: dist/*
- name: upload artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.parallel }}-${{ matrix.python }}-${{ matrix.os }}-${{ matrix.plat }}
path: dist
retention-days: 2
pypi:
name: pypi
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: build source dist (serial)
env:
TAG_STRING: ${{ github.event.ref }}
run: |
echo ${TAG_STRING:11}
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py
python -m pip install pip build twine setuptools --upgrade
python -m build --sdist
- name: release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: dist/*
- name: build index
env:
REPO: ${{ github.repository }}
run: |
python .github/workflows/build_pypi.py ${REPO} ./idx-dist/pypi
- name: setup pages
uses: actions/configure-pages@v5
- name: upload artifacts
uses: actions/upload-pages-artifact@v3
with:
path: './idx-dist'
- name: deploy to gitHub pages
id: deployment
uses: actions/deploy-pages@v4
publish:
name: publish
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: build source dist (serial)
env:
TAG_STRING: ${{ github.event.ref }}
run: |
echo ${TAG_STRING:11}
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py
python -m pip install pip build twine setuptools --upgrade
python -m build --sdist
- name: download wheels
uses: actions/download-artifact@v4
with:
pattern: dist-serial-*
path: dist
merge-multiple: true
- name: publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1