Skip to content

Commit 900163e

Browse files
committed
use cibuildwheel for win and travis
Co-authored by: nijincheng@iscas.ac.cn;
1 parent d386f0e commit 900163e

14 files changed

+359
-566
lines changed

.github/workflows/posix.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.

.github/workflows/wheel.yml

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
name: build-wheel
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch: null
9+
schedule:
10+
- cron: '0 0 * * 0'
11+
12+
env:
13+
REPO_DIR: OpenBLAS
14+
OPENBLAS_COMMIT: "v0.3.30"
15+
MACOSX_DEPLOYMENT_TARGET: 10.9
16+
OPENBLAS_ROOT: "c:\\opt"
17+
# Preserve working directory for calls into bash
18+
# Without this, invoking bash will cd to the home directory
19+
CHERE_INVOKING: "yes"
20+
21+
jobs:
22+
build:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
29+
30+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
31+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
32+
33+
- { os: macos-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx}
34+
- { os: macos-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx}
35+
36+
- { os: macos-latest, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx}
37+
- { os: macos-latest, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx}
38+
39+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
40+
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
41+
42+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
43+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
44+
45+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
46+
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
47+
48+
49+
- { os: windows-latest, PLAT: amd64, INTERFACE64: '1', MB_ML_LIBC: win}
50+
- { os: windows-latest, PLAT: amd64, INTERFACE64: '0', MB_ML_LIBC: win}
51+
- { os: windows-latest, PLAT: x86, INTERFACE64: '0', MB_ML_LIBC: win}
52+
53+
- { os: windows-11-arm, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: win}
54+
- { os: windows-11-arm, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: win}
55+
56+
env:
57+
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
58+
MB_ML_LIBC: ${{ matrix.MB_ML_LIBC }}
59+
MB_ML_VER: ${{ matrix.MB_ML_VER }}
60+
INTERFACE64: ${{ matrix.INTERFACE64 }}
61+
BUILD_DIR: ${{ github.workspace }}
62+
PLAT: ${{ matrix.PLAT }}
63+
OS-NAME: ${{ matrix.os }}
64+
65+
steps:
66+
- uses: actions/checkout@v4.1.1
67+
with:
68+
submodules: recursive
69+
fetch-depth: 0
70+
71+
- uses: maxim-lobanov/setup-xcode@v1.6.0
72+
if: ${{ contains(matrix.os, 'macos') }}
73+
with:
74+
xcode-version: '16.0'
75+
76+
- name: Print some Environment variable
77+
run: |
78+
echo "PLAT: ${PLAT}"
79+
- name: install-rtools
80+
if: ${{ matrix.os == 'windows-latest' }}
81+
run: |
82+
# rtools 42+ does not support 32 bits builds.
83+
choco install -y rtools --no-progress --force --version=4.0.0.20220206
84+
85+
- name: Set env variables
86+
if: ${{ matrix.os == 'windows-latest' }}
87+
run: |
88+
echo "START_DIR=$PWD" >> $env:GITHUB_ENV
89+
# For interpretation of MSYSTEM, see:
90+
# https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939
91+
if ( "${{ matrix.plat }}" -eq "x86") {
92+
echo "PLAT=i686" >> $env:GITHUB_ENV
93+
echo "WHEEL_PLAT=win32" >> $env:GITHUB_ENV
94+
echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV
95+
# No ucrt on 32-bits, so use _snprintf_c instead
96+
echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $env:GITHUB_ENV
97+
echo "BUILD_BITS=32" >> $env:GITHUB_ENV
98+
} else {
99+
echo "PLAT=x86_64" >> $env:GITHUB_ENV
100+
echo "WHEEL_PLAT=win_amd64" >> $env:GITHUB_ENV
101+
echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV
102+
echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV
103+
echo "BUILD_BITS=64" >> $env:GITHUB_ENV
104+
}
105+
if ( ${{ matrix.INTERFACE64 }} -eq "1" ) {
106+
echo "INTERFACE64=1" >> $env:GITHUB_ENV
107+
}
108+
$CIBW = "${{ github.workspace }}/.openblas"
109+
$CIBW = $CIBW.replace("\","/")
110+
echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $env:GITHUB_ENV
111+
112+
- name: Debug
113+
if: ${{ matrix.os == 'windows-latest' }}
114+
run: |
115+
echo CIBW_ENVIRONMENT_WINDOWS=$env:CIBW_ENVIRONMENT_WINDOWS
116+
117+
- name: Setup visual studio
118+
if: ${{ matrix.os == 'windows-11-arm' }}
119+
uses: microsoft/setup-msbuild@v2
120+
121+
- name: Download, install 7zip.
122+
if: ${{ matrix.os == 'windows-11-arm' }}
123+
run: |
124+
Invoke-WebRequest https://www.7-zip.org/a/7z2409-arm64.exe -UseBasicParsing -OutFile 7z_arm.exe
125+
Start-Process -FilePath ".\7z_arm.exe" -ArgumentList "/S" -Wait
126+
echo "C:\Program Files\7-Zip" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
127+
128+
- name: Download and install LLVM installer
129+
if: ${{ matrix.os == 'windows-11-arm' }}
130+
run: |
131+
Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/LLVM-19.1.5-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe
132+
Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait
133+
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
134+
135+
- name: Update CMake for WoA
136+
if: ${{ matrix.os == 'windows-11-arm' }}
137+
run: |
138+
pip install cmake
139+
get-command cmake
140+
- name: Set env variables
141+
if: ${{ matrix.os == 'windows-11-arm' }}
142+
run: |
143+
if ( ${{ matrix.INTERFACE64 }} -eq "1" ) {
144+
echo "INTERFACE_BITS=64" >> $env:GITHUB_ENV
145+
} else {
146+
echo "INTERFACE_BITS=32" >> $env:GITHUB_ENV
147+
}
148+
149+
150+
# - name: Setup tmate session
151+
# if: ${{ failure() }}
152+
# uses: mxschmitt/action-tmate@v3
153+
# with:
154+
# limit-access-to-actor: true
155+
156+
- name: Build OpenBLAS for Windows
157+
if: ${{ matrix.os == 'windows-latest' }}
158+
run: |
159+
Set-Item -Path env:BASH_PATH -Value "c:\\rtools40\\usr\\bin\\bash.exe"
160+
# Build
161+
& $env:BASH_PATH -lc tools/build_openblas.sh
162+
163+
# Test
164+
& $env:BASH_PATH -lc tools/build_gfortran.sh
165+
echo "Static test"
166+
.\for_test\test.exe
167+
echo "Dynamic test"
168+
.\for_test\test_dyn.exe
169+
170+
# Copy
171+
cp for_test\test*.exe builds
172+
173+
bash tools/build_wheel_prepare_for_win.sh
174+
- name: Build OpenBLAS for Windows On ARM
175+
if: ${{ matrix.os == 'windows-11-arm' }}
176+
run: |
177+
Set-Item -Path env:BASH_PATH -Value "C:\\Program Files\\Git\\bin\\bash.exe"
178+
.\tools\build_steps_win_arm64.bat 64 ${env:INTERFACE_BITS}
179+
180+
- name: Set CIBW_BUILD
181+
shell: bash
182+
run: |
183+
if [[ "${{ matrix.os }}" == "windows-latest" && "${{matrix.PLAT}}" == "x86" ]]; then
184+
echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}32" >> $GITHUB_ENV
185+
else
186+
echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}_${{ matrix.PLAT }}" >> $GITHUB_ENV
187+
fi
188+
189+
- name: Build and Test wheels
190+
uses: pypa/cibuildwheel@v3.1.4
191+
with:
192+
output-dir: dist
193+
env:
194+
CIBW_BUILD_VERBOSITY: 1
195+
196+
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
197+
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
198+
CIBW_MUSLLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
199+
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
200+
CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
201+
202+
- name: Upload wheels to artifacts
203+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'macos-latest' }}
204+
uses: actions/upload-artifact@v4.3.0
205+
with:
206+
name: wheels-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
207+
path: dist/scipy_openblas*.whl
208+
209+
210+
- name: Upload openblas to artifacts
211+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' || matrix.os == 'macos-latest' }}
212+
uses: actions/upload-artifact@v4.3.0
213+
with:
214+
name: openblas-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
215+
path: dist/openblas*.tar.gz
216+
- name: Pack
217+
if: ${{ matrix.os == 'windows-11-arm' }}
218+
run: |
219+
cd local
220+
cp -r "scipy_openblas${env:INTERFACE_BITS}" $env:INTERFACE_BITS
221+
7z a ../builds/openblas-${env:PLAT}-${env:INTERFACE64}.zip -tzip $env:INTERFACE_BITS
222+
223+
- uses: actions/upload-artifact@v4.3.0
224+
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm' }}
225+
with:
226+
name: wheels-${{matrix.plat }}-${{ matrix.INTERFACE64 }}
227+
path: dist/scipy_openblas*.whl
228+
229+
- uses: actions/upload-artifact@v4.3.0
230+
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm' }}
231+
with:
232+
name: openblas-${{matrix.plat }}-${{ matrix.INTERFACE64 }}
233+
path: builds/openblas*.zip
234+
- name: Install Anaconda client
235+
if: ${{ matrix.os == 'windows-11-arm' }}
236+
run: |
237+
pip install anaconda-client
238+
239+
- uses: conda-incubator/setup-miniconda@v3.2.0
240+
if: ${{ matrix.os != 'windows-11-arm' }}
241+
with:
242+
channels: conda-forge
243+
channel-priority: true
244+
activate-environment: upload
245+
miniforge-version: latest
246+
conda-remove-defaults: "true"
247+
- name: install anaconda client
248+
if: ${{ matrix.os != 'windows-11-arm' }}
249+
run: |
250+
conda install anaconda-client
251+
- name: Upload
252+
# see https://github.com/marketplace/actions/setup-miniconda for why
253+
# `-el {0}` is required.
254+
shell: bash -el {0}
255+
env:
256+
ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }}
257+
run: |
258+
source tools/upload_to_anaconda_staging.sh
259+
upload_wheels

0 commit comments

Comments
 (0)