8000 add OS/BLAS pip-based test matrix as GitHub workflow · python-control/python-control@9d72d79 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d72d79

Browse files
committed
add OS/BLAS pip-based test matrix as GitHub workflow
1 parent 56f227f commit 9d72d79

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
""" set-pip-test-matrix.py
2+
3+
Create test matrix for pip wheels
4+
"""
5+
import json
6+
from pathlib import Path
7+
8+
system_opt_blas_libs = {'ubuntu': ['OpenBLAS'],
9+
'macos' : ['OpenBLAS', 'Apple']}
10+
11+
wheel_jobs = []
12+
for wkey in Path("slycot-wheels").iterdir():
13+
wos, wpy, wbl = wkey.name.split("-")
14+
wheel_jobs.append({'packagekey': wkey.name,
15+
'os': wos,
16+
'python': wpy,
17+
'blas_lib': wbl,
18+
})
19+
if wbl == "Generic":
20+
for bl in system_opt_blas_libs[wos]:
21+
wheel_jobs.append({ 'packagekey': wkey.name,
22+
'os': wos,
23+
'python': wpy,
24+
'blas_lib': bl,
25+
})
26+
27+
matrix = { 'include': wheel_jobs }
28+
print(json.dumps(matrix))
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: OS/BLAS test matrix
2+
3+
on: push
4+
5+
jobs:
6+
build-pip:
7+
name: Build pip Py${{ matrix.python }}, ${{ matrix.os }}, ${{ matrix.bla_vendor}} BLA_VENDOR
8+
runs-on: ${{ matrix.os }}-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os:
13+
- 'ubuntu'
14+
- 'macos'
15+
python:
16+
- '3.8'
17+
- '3.11'
18+
bla_vendor: [ 'unset' ]
19+
include:
20+
- os: 'ubuntu'
21+
python: '3.11'
22+
bla_vendor: 'Generic'
23+
- os: 'ubuntu'
24+
python: '3.11'
25+
bla_vendor: 'OpenBLAS'
26+
- os: 'macos'
27+
python: '3.11'
28+
bla_vendor: 'Apple'
29+
- os: 'macos'
30+
python: '3.11'
31+
bla_vendor: 'Generic'
32+
- os: 'macos'
33+
python: '3.11'
34+
bla_vendor: 'OpenBLAS'
35+
36+
steps:
37+
- name: Set up Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: ${{ matrix.python }}
41+
- name: Checkout Slycot
42+
uses: actions/checkout@v3
43+
with:
44+
repository: python-control/Slycot
45+
fetch-depth: 0
46+
submodules: 'recursive'
47+
- name: Setup Ubuntu
48+
if: matrix.os == 'ubuntu'
49+
run: |
50+
sudo apt-get -y update
51+
sudo apt-get -y install gfortran cmake --fix-missing
52+
case ${{ matrix.bla_vendor }} in
53+
unset | Generic ) sudo apt-get -y install libblas-dev liblapack-dev ;;
54+
OpenBLAS ) sudo apt-get -y install libopenblas-dev ;;
55+
*)
56+
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
57+
exit 1 ;;
58+
esac
59+
- name: Setup macOS
60+
if: matrix.os == 'macos'
61+
run: |
62+
case ${{ matrix.bla_vendor }} in
63+
unset | Generic | Apple ) ;; # Found in system
64+
OpenBLAS )
65+
brew install openblas
66+
echo "BLAS_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
67+
echo "LAPACK_ROOT=/usr/local/opt/openblas/" >> $GITHUB_ENV
68+
;;
69+
*)
70+
echo "bla_vendor option ${{ matrix.bla_vendor }} not supported"
71+
exit 1 ;;
72+
esac
73+
echo "FC=gfortran-11" >> $GITHUB_ENV
74+
- name: Build wheel
75+
env:
76+
BLA_VENDOR: ${{ matrix.bla_vendor }}
77+
CMAKE_GENERATOR: Unix Makefiles
78+
run: |
79+
if [[ $BLA_VENDOR = unset ]]; then unset BLA_VENDOR; fi
80+
python -m pip install --upgrade pip
81+
pip wheel -v -w . .
82+
wheeldir=slycot-wheels/${{ matrix.os }}-${{ matrix.python }}-${{ matrix.bla_vendor }}
83+
mkdir -p ${wheeldir}
84+
cp ./slycot*.whl ${wheeldir}/
85+
- name: Save wheel
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: slycot-wheels
89+
path: slycot-wheels
90+
91+
92+
create-wheel-test-matrix:
93+
name: Create wheel test matrix
94+
runs-on: ubuntu-latest
95+
needs: build-pip
96+
if: always() # run tests for all successful builds, even if others failed
97+
outputs:
98+
matrix: ${{ steps.set-matrix.outputs.matrix }}
99+
steps:
100+
- name: Checkout python-control
101+
uses: actions/checkout@v3
102+
- name: Download wheels (if any)
103+
uses: actions/download-artifact@v3
104+
with:
105+
name: slycot-wheels
106+
path: slycot-wheels
107+
- id: set-matrix
108+
run: echo "matrix=$(python3 .github/scripts/set-pip-test-matrix.py)" >> $GITHUB_OUTPUT
109+
110+
111+
test-wheel:
112+
name: Test wheel ${{ matrix.packagekey }}, ${{matrix.blas_lib}} BLAS lib ${{ matrix.failok }}
113+
needs: create-wheel-test-matrix
114+
runs-on: ${{ matrix.os }}-latest
115+
continue-on-error: ${{ matrix.failok == 'FAILOK' }}
116+
117+
strategy:
118+
fail-fast: false
119+
matrix: ${{ fromJSON(needs.create-wheel-test-matrix.outputs.matrix) }}
120+
121+
steps:
122+
- name: Checkout Slycot
123+
uses: actions/checkout@v3
124+
with:
125+
repository: 'python-control/Slycot'
126+
path: slycot-src
127+
- name: Checkout python-control
128+
uses: actions/checkout@v3
129+
with:
130+
repository: 'python-control/python-control'
131+
- name: Setup Python
132+
uses: actions/setup-python@v4
133+
with:
134+
python-version: ${{ matrix.python }}
135+
- name: Setup Ubuntu
136+
if: matrix.os == 'ubuntu'
137+
run: |
138+
set -xe
139+
sudo apt-get -y update
140+
case ${{ matrix.blas_lib }} in
141+
Generic ) sudo apt-get -y install libblas3 liblapack3 ;;
142+
unset | OpenBLAS ) sudo apt-get -y install libopenblas-base ;;
143+
*)
144+
echo "BLAS ${{ matrix.blas_lib }} not supported for wheels on Ubuntu"
145+
exit 1 ;;
146+
esac
147+
update-alternatives --display libblas.so.3-x86_64-linux-gnu
148+
update-alternatives --display liblapack.so.3-x86_64-linux-gnu
149+
- name: Setup macOS
150+
if: matrix.os == 'macos'
151+
run: |
152+
set -xe
153+
brew install coreutils
154+
case ${{ matrix.blas_lib }} in
155+
unset | Generic | Apple ) ;; # system provided (Uses Apple Accelerate Framework)
156+
OpenBLAS )
157+
brew install openblas
158+
echo "DYLIB_LIBRARY_PATH=/usr/local/opt/openblas/lib" >> $GITHUB_ENV
159+
;;
160+
*)
161+
echo "BLAS option ${{ matrix.blas_lib }} not supported for wheels on MacOS"
162+
exit 1 ;;
163+
esac
164+
- name: Download wheels
165+
uses: actions/download-artifact@v3
166+
with:
167+
name: slycot-wheels
168+
path: slycot-wheels
169+
- name: Install Wheel
170+
run: |
171+
python -m pip install --upgrade pip
172+
pip install matplotlib scipy pytest pytest-cov pytest-timeout coverage coveralls
173+
pip install slycot-wheels/${{ matrix.packagekey }}/slycot*.whl
174+
pip show slycot
175+
- name: Test with pytest
176+
run: pytest -v control/tests

0 commit comments

Comments
 (0)
0