Skip to content

Commit 4b29f63

Browse files
committed
use cibuildwheel for win
Co-authored by: nijincheng@iscas.ac.cn; Signed-off-by: ffgan <sudoemt@gmail.com>
1 parent 0dfedf0 commit 4b29f63

File tree

9 files changed

+280
-335
lines changed

9 files changed

+280
-335
lines changed

.github/workflows/posix.yml

Lines changed: 189 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,40 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
include:
24-
- { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
24+
- { os: ubuntu-latest, PLAT: i686, ARCH: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
2525

26-
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
27-
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
26+
- { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
27+
- { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
2828

29-
- { os: macos-14, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx}
30-
- { os: macos-14, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx}
29+
- { os: macos-14, PLAT: x86_64, ARCh: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx}
30+
- { os: macos-14, PLAT: x86_64, ARCh: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx}
3131

32-
- { os: macos-latest, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx}
33-
- { os: macos-latest, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx}
32+
- { os: macos-latest, PLAT: arm64, ARCH: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx}
33+
- { os: macos-latest, PLAT: arm64, ARCH: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx}
3434

35-
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
36-
- { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
35+
- { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
36+
- { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
3737

38-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
39-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
38+
- { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
39+
- { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
4040

41-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
42-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
41+
- { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
42+
- { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
4343

44-
- { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
45-
- { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
44+
- { os: ubuntu-24.04-arm, PLAT: ppc64le, ARCH: ppc64le, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
45+
- { os: ubuntu-24.04-arm, PLAT: ppc64le, ARCH: ppc64le, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
46+
47+
- { os: ubuntu-24.04-arm, PLAT: s390x, ARCH: s390x, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
48+
- { os: ubuntu-24.04-arm, PLAT: s390x, ARCH: s390x, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
49+
50+
51+
- { os: windows-latest, PLAT: amd64, PYTHON_PLAT: x64, ARCH: AMD64, INTERFACE64: '1', MB_ML_LIBC: win}
52+
- { os: windows-latest, PLAT: amd64, PYTHON_PLAT: x64, ARCH: AMD64, INTERFACE64: '0', MB_ML_LIBC: win}
53+
- { os: windows-latest, PLAT: x86, PYTHON_PLAT: x86, ARCH: x86, INTERFACE64: '0', MB_ML_LIBC: win}
54+
55+
- { os: windows-11-arm, PLAT: arm64, ARCH: ARM64, INTERFACE64: '1', MB_ML_LIBC: win}
56+
- { os: windows-11-arm, PLAT: arm64, ARCH: ARM64, INTERFACE64: '0', MB_ML_LIBC: win}
4657

47-
- { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
48-
- { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
4958

5059
env:
5160
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
@@ -88,15 +97,158 @@ jobs:
8897
# with:
8998
# limit-access-to-actor: true
9099

100+
- name: install-rtools
101+
if: ${{ matrix.os == 'windows-latest' }}
102+
run: |
103+
# rtools 42+ does not support 32 bits builds.
104+
choco install -y rtools --no-progress --force --version=4.0.0.20220206
105+
106+
- name: Set env variables
107+
if: ${{ matrix.os == 'windows-latest' }}
108+
run: |
109+
echo "START_DIR=$PWD" >> $GITHUB_ENV
110+
# For interpretation of MSYSTEM, see:
111+
# https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939
112+
if [ "${{ matrix.plat }}" = "x86" ]; then
113+
echo "PLAT=i686" >> $GITHUB_ENV
114+
echo "WHEEL_PLAT=win32" >> $GITHUB_ENV
115+
echo "MSYSTEM=MINGW32" >> $GITHUB_ENV
116+
# No ucrt on 32-bits, so use _snprintf_c instead
117+
echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $GITHUB_ENV
118+
echo "BUILD_BITS=32" >> $GITHUB_ENV
119+
else
120+
echo "PLAT=x86_64" >> $GITHUB_ENV
121+
echo "WHEEL_PLAT=win_amd64" >> $GITHUB_ENV
122+
echo "MSYSTEM=UCRT64" >> $GITHUB_ENV
123+
echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $GITHUB_ENV
124+
echo "BUILD_BITS=64" >> $GITHUB_ENV
125+
fi
126+
if [ ${{ matrix.INTERFACE64 }} = "1" ]; then
127+
echo "INTERFACE64=1" >> $GITHUB_ENV
128+
fi
129+
CIBW="${{ github.workspace }}/.openblas"
130+
CIBW="${CIBW//\\//}"
131+
echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $GITHUB_ENV
132+
133+
- name: Debug
134+
if: ${{ matrix.os == 'windows-latest' }}
135+
run: |
136+
echo CIBW_ENVIRONMENT_WINDOWS=$CIBW_ENVIRONMENT_WINDOWS
137+
138+
- name: Setup visual studio
139+
if: ${{ matrix.os == 'windows-11-arm' }}
140+
uses: microsoft/setup-msbuild@v2
141+
142+
- name: Download, install 7zip.
143+
if: ${{ matrix.os == 'windows-11-arm' }}
144+
shell: pwsh
145+
run: |
146+
Invoke-WebRequest https://www.7-zip.org/a/7z2409-arm64.exe -UseBasicParsing -OutFile 7z_arm.exe
147+
Start-Process -FilePath ".\7z_arm.exe" -ArgumentList "/S" -Wait
148+
echo "C:\Program Files\7-Zip" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
149+
150+
- name: Download and install LLVM installer
151+
if: ${{ matrix.os == 'windows-11-arm' }}
152+
shell: pwsh
153+
run: |
154+
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
155+
Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait
156+
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
157+
158+
- name: Update CMake for WoA
159+
if: ${{ matrix.os == 'windows-11-arm' }}
160+
run: |
161+
pip install cmake
162+
which cmake
163+
- name: Set env variables
164+
if: ${{ matrix.os == 'windows-11-arm' }}
165+
run: |
166+
if [ "${{ matrix.INTERFACE64 }}" = "1" ]; then
167+
echo "INTERFACE_BITS=64" >> $GITHUB_ENV
168+
else
169+
echo "INTERFACE_BITS=32" >> $GITHUB_ENV
170+
fi
171+
172+
173+
# - name: Setup tmate session
174+
# if: ${{ failure() }}
175+
# uses: mxschmitt/action-tmate@v3
176+
# with:
177+
# limit-access-to-actor: true
178+
179+
- name: Build OpenBLAS for Windows
180+
if: ${{ matrix.os == 'windows-latest' }}
181+
shell: pwsh
182+
env:
183+
OPENBLAS_ROOT: "c:\\opt"
184+
BASH_PATH: "c:/rtools40/usr/bin/bash.exe"
185+
CHERE_INVOKING: "yes"
186+
run: |
187+
& $env:BASH_PATH -lc ./tools/build_steps_windows.sh
188+
189+
- name: Set up Python
190+
if: ${{ matrix.os == 'windows-latest' }}
191+
uses: actions/setup-python@v5
192+
with:
193+
python-version: 3.9
194+
architecture: ${{ matrix.PYTHON_PLAT }}
195+
196+
- name: Test OpenBLAS for Windows
197+
if: ${{ matrix.os == 'windows-latest' }}
198+
shell: pwsh
199+
env:
200+
OPENBLAS_ROOT: "c:\\opt"
201+
BASH_PATH: "c:/rtools40/usr/bin/bash.exe"
202+
CHERE_INVOKING: "yes"
203+
run: |
204+
& $env:BASH_PATH -lc tools/build_gfortran.sh
205+
206+
207+
# Test
208+
echo "Static test"
209+
.\for_test\test.exe
210+
echo "Dynamic test"
211+
.\for_test\test_dyn.exe
212+
213+
# Copy
214+
cp for_test\test*.exe builds
215+
216+
- name: prepare wheel
217+
run: |
218+
./tools/build_wheel_prepare_for_win.sh
219+
220+
- name: Set up Python
221+
if: ${{ matrix.os == 'windows-latest' }}
222+
uses: actions/setup-python@v5
223+
with:
224+
python-version: 3.9
225+
architecture: ${{ matrix.PYTHON_PLAT }}
226+
227+
- name: Build OpenBLAS for Windows On ARM
228+
if: ${{ matrix.os == 'windows-11-arm' }}
229+
run: |
230+
export BASH_PATH="C:/Program Files/Git/bin/bash.exe"
231+
./tools/build_steps_win_arm64.bat 64 $INTERFACE_BITS
232+
233+
- name: Set CIBW_BUILD
234+
run: |
235+
if [[ "${{ matrix.os }}" == "windows-latest" && "${{matrix.PLAT}}" == "x86" ]]; then
236+
echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}32" >> $GITHUB_ENV
237+
else
238+
echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}_${{ matrix.PLAT }}" >> $GITHUB_ENV
239+
fi
240+
241+
242+
243+
91244
- name: Build and Test wheels
92245
uses: pypa/cibuildwheel@v3.3.0
93246
timeout-minutes: 60
94247
with:
95248
output-dir: dist
96249
env:
97-
CIBW_ARCHS: ${{matrix.PLAT}}
250+
CIBW_ARCHS: ${{matrix.ARCH}}
98251
CIBW_BUILD_VERBOSITY: 1
99-
CIBW_BUILD: "cp39-${{ matrix.MB_ML_LIBC }}_${{matrix.PLAT}}"
100252

101253
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
102254
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
@@ -114,22 +266,39 @@ jobs:
114266
name: wheels-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }}
115267
path: dist/scipy_openblas*.whl
116268

269+
- name: Install Anaconda client
270+
if: ${{ matrix.os == 'windows-11-arm' }}
271+
run: |
272+
pip install anaconda-client
117273
118274
- uses: conda-incubator/setup-miniconda@v3.2.0
275+
if: ${{ matrix.os != 'windows-latest' && matrix.os != 'windows-11-arm' }}
119276
with:
120277
channels: conda-forge
121278
channel-priority: true
122279
activate-environment: upload
123280
miniforge-version: latest
124281
conda-remove-defaults: "true"
125282

283+
- uses: conda-incubator/setup-miniconda@v3.1.1
284+
if: ${{ matrix.os == 'windows-latest' }}
285+
with:
286+
channels: conda-forge
287+
channel-priority: true
288+
activate-environment: upload
289+
miniforge-version: latest
290+
291+
- name: install anaconda-client
292+
if: ${{ matrix.os != 'windows-11-arm' }}
293+
shell: pwsh
294+
run: conda install -y anaconda-client
295+
126296
- name: Upload
127297
# see https://github.com/marketplace/actions/setup-miniconda for why
128298
# `-el {0}` is required.
129299
shell: bash -el {0}
130300
env:
131301
ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }}
132302
run: |
133-
conda install -y anaconda-client
134303
source tools/upload_to_anaconda_staging.sh
135304
upload_wheels

.github/workflows/windows-arm.yml

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

0 commit comments

Comments
 (0)