From 4b29f63b132d418794c0d0f150902742839672f9 Mon Sep 17 00:00:00 2001 From: ffgan Date: Fri, 19 Dec 2025 21:56:49 +0800 Subject: [PATCH 1/2] use cibuildwheel for win Co-authored by: nijincheng@iscas.ac.cn; Signed-off-by: ffgan --- .github/workflows/posix.yml | 209 ++++++++++++++++++++++++--- .github/workflows/windows-arm.yml | 98 ------------- .github/workflows/windows.yml | 180 ----------------------- pyproject.toml | 19 ++- tools/build_steps_win_arm64.bat | 36 +---- tools/build_wheel_prepare_for_win.sh | 36 +++++ tools/repair_for_win.sh | 14 ++ tools/repair_for_win_arm64.bat | 14 ++ tools/test_for_win.sh | 9 ++ 9 files changed, 280 insertions(+), 335 deletions(-) delete mode 100644 .github/workflows/windows-arm.yml delete mode 100644 .github/workflows/windows.yml create mode 100644 tools/build_wheel_prepare_for_win.sh create mode 100644 tools/repair_for_win.sh create mode 100644 tools/repair_for_win_arm64.bat create mode 100644 tools/test_for_win.sh diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index 6d4fe645..3001eeb0 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -21,31 +21,40 @@ jobs: fail-fast: false matrix: include: - - { os: ubuntu-latest, PLAT: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-latest, PLAT: i686, ARCH: i686, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: macos-14, PLAT: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx} - - { os: macos-14, PLAT: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx} + - { os: macos-14, PLAT: x86_64, ARCh: x86_64, INTERFACE64: '0', MB_ML_LIBC: macosx} + - { os: macos-14, PLAT: x86_64, ARCh: x86_64, INTERFACE64: '1', MB_ML_LIBC: macosx} - - { os: macos-latest, PLAT: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx} - - { os: macos-latest, PLAT: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx} + - { os: macos-latest, PLAT: arm64, ARCH: arm64, INTERFACE64: '0', MB_ML_LIBC: macosx} + - { os: macos-latest, PLAT: arm64, ARCH: arm64, INTERFACE64: '1', MB_ML_LIBC: macosx} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} - - { os: ubuntu-latest, PLAT: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} + - { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} + - { os: ubuntu-latest, PLAT: x86_64, ARCH: x86_64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} - - { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} - - { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} + - { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} + - { os: ubuntu-24.04-arm, PLAT: aarch64, ARCH: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux} - - { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-24.04-arm, PLAT: ppc64le, ARCH: ppc64le, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-24.04-arm, PLAT: ppc64le, ARCH: ppc64le, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + + - { os: ubuntu-24.04-arm, PLAT: s390x, ARCH: s390x, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + - { os: ubuntu-24.04-arm, PLAT: s390x, ARCH: s390x, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} + + + - { os: windows-latest, PLAT: amd64, PYTHON_PLAT: x64, ARCH: AMD64, INTERFACE64: '1', MB_ML_LIBC: win} + - { os: windows-latest, PLAT: amd64, PYTHON_PLAT: x64, ARCH: AMD64, INTERFACE64: '0', MB_ML_LIBC: win} + - { os: windows-latest, PLAT: x86, PYTHON_PLAT: x86, ARCH: x86, INTERFACE64: '0', MB_ML_LIBC: win} + + - { os: windows-11-arm, PLAT: arm64, ARCH: ARM64, INTERFACE64: '1', MB_ML_LIBC: win} + - { os: windows-11-arm, PLAT: arm64, ARCH: ARM64, INTERFACE64: '0', MB_ML_LIBC: win} - - { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} - - { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux} env: NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} @@ -88,15 +97,158 @@ jobs: # with: # limit-access-to-actor: true + - name: install-rtools + if: ${{ matrix.os == 'windows-latest' }} + run: | + # rtools 42+ does not support 32 bits builds. + choco install -y rtools --no-progress --force --version=4.0.0.20220206 + + - name: Set env variables + if: ${{ matrix.os == 'windows-latest' }} + run: | + echo "START_DIR=$PWD" >> $GITHUB_ENV + # For interpretation of MSYSTEM, see: + # https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939 + if [ "${{ matrix.plat }}" = "x86" ]; then + echo "PLAT=i686" >> $GITHUB_ENV + echo "WHEEL_PLAT=win32" >> $GITHUB_ENV + echo "MSYSTEM=MINGW32" >> $GITHUB_ENV + # No ucrt on 32-bits, so use _snprintf_c instead + echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $GITHUB_ENV + echo "BUILD_BITS=32" >> $GITHUB_ENV + else + echo "PLAT=x86_64" >> $GITHUB_ENV + echo "WHEEL_PLAT=win_amd64" >> $GITHUB_ENV + echo "MSYSTEM=UCRT64" >> $GITHUB_ENV + echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $GITHUB_ENV + echo "BUILD_BITS=64" >> $GITHUB_ENV + fi + if [ ${{ matrix.INTERFACE64 }} = "1" ]; then + echo "INTERFACE64=1" >> $GITHUB_ENV + fi + CIBW="${{ github.workspace }}/.openblas" + CIBW="${CIBW//\\//}" + echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $GITHUB_ENV + + - name: Debug + if: ${{ matrix.os == 'windows-latest' }} + run: | + echo CIBW_ENVIRONMENT_WINDOWS=$CIBW_ENVIRONMENT_WINDOWS + + - name: Setup visual studio + if: ${{ matrix.os == 'windows-11-arm' }} + uses: microsoft/setup-msbuild@v2 + + - name: Download, install 7zip. + if: ${{ matrix.os == 'windows-11-arm' }} + shell: pwsh + run: | + Invoke-WebRequest https://www.7-zip.org/a/7z2409-arm64.exe -UseBasicParsing -OutFile 7z_arm.exe + Start-Process -FilePath ".\7z_arm.exe" -ArgumentList "/S" -Wait + echo "C:\Program Files\7-Zip" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Download and install LLVM installer + if: ${{ matrix.os == 'windows-11-arm' }} + shell: pwsh + run: | + 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 + Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait + echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Update CMake for WoA + if: ${{ matrix.os == 'windows-11-arm' }} + run: | + pip install cmake + which cmake + - name: Set env variables + if: ${{ matrix.os == 'windows-11-arm' }} + run: | + if [ "${{ matrix.INTERFACE64 }}" = "1" ]; then + echo "INTERFACE_BITS=64" >> $GITHUB_ENV + else + echo "INTERFACE_BITS=32" >> $GITHUB_ENV + fi + + + # - name: Setup tmate session + # if: ${{ failure() }} + # uses: mxschmitt/action-tmate@v3 + # with: + # limit-access-to-actor: true + + - name: Build OpenBLAS for Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + env: + OPENBLAS_ROOT: "c:\\opt" + BASH_PATH: "c:/rtools40/usr/bin/bash.exe" + CHERE_INVOKING: "yes" + run: | + & $env:BASH_PATH -lc ./tools/build_steps_windows.sh + + - name: Set up Python + if: ${{ matrix.os == 'windows-latest' }} + uses: actions/setup-python@v5 + with: + python-version: 3.9 + architecture: ${{ matrix.PYTHON_PLAT }} + + - name: Test OpenBLAS for Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + env: + OPENBLAS_ROOT: "c:\\opt" + BASH_PATH: "c:/rtools40/usr/bin/bash.exe" + CHERE_INVOKING: "yes" + run: | + & $env:BASH_PATH -lc tools/build_gfortran.sh + + + # Test + echo "Static test" + .\for_test\test.exe + echo "Dynamic test" + .\for_test\test_dyn.exe + + # Copy + cp for_test\test*.exe builds + + - name: prepare wheel + run: | + ./tools/build_wheel_prepare_for_win.sh + + - name: Set up Python + if: ${{ matrix.os == 'windows-latest' }} + uses: actions/setup-python@v5 + with: + python-version: 3.9 + architecture: ${{ matrix.PYTHON_PLAT }} + + - name: Build OpenBLAS for Windows On ARM + if: ${{ matrix.os == 'windows-11-arm' }} + run: | + export BASH_PATH="C:/Program Files/Git/bin/bash.exe" + ./tools/build_steps_win_arm64.bat 64 $INTERFACE_BITS + + - name: Set CIBW_BUILD + run: | + if [[ "${{ matrix.os }}" == "windows-latest" && "${{matrix.PLAT}}" == "x86" ]]; then + echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}32" >> $GITHUB_ENV + else + echo "CIBW_BUILD=cp39-${{ matrix.MB_ML_LIBC }}_${{ matrix.PLAT }}" >> $GITHUB_ENV + fi + + + + - name: Build and Test wheels uses: pypa/cibuildwheel@v3.3.0 timeout-minutes: 60 with: output-dir: dist env: - CIBW_ARCHS: ${{matrix.PLAT}} + CIBW_ARCHS: ${{matrix.ARCH}} CIBW_BUILD_VERBOSITY: 1 - CIBW_BUILD: "cp39-${{ matrix.MB_ML_LIBC }}_${{matrix.PLAT}}" CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}} @@ -114,8 +266,13 @@ jobs: name: wheels-${{ matrix.os }}-${{ matrix.PLAT }}-${{ matrix.INTERFACE64 }}-${{ matrix.MB_ML_LIBC }}-${{ matrix.MB_ML_VER }} path: dist/scipy_openblas*.whl + - name: Install Anaconda client + if: ${{ matrix.os == 'windows-11-arm' }} + run: | + pip install anaconda-client - uses: conda-incubator/setup-miniconda@v3.2.0 + if: ${{ matrix.os != 'windows-latest' && matrix.os != 'windows-11-arm' }} with: channels: conda-forge channel-priority: true @@ -123,6 +280,19 @@ jobs: miniforge-version: latest conda-remove-defaults: "true" + - uses: conda-incubator/setup-miniconda@v3.1.1 + if: ${{ matrix.os == 'windows-latest' }} + with: + channels: conda-forge + channel-priority: true + activate-environment: upload + miniforge-version: latest + + - name: install anaconda-client + if: ${{ matrix.os != 'windows-11-arm' }} + shell: pwsh + run: conda install -y anaconda-client + - name: Upload # see https://github.com/marketplace/actions/setup-miniconda for why # `-el {0}` is required. @@ -130,6 +300,5 @@ jobs: env: ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }} run: | - conda install -y anaconda-client source tools/upload_to_anaconda_staging.sh upload_wheels diff --git a/.github/workflows/windows-arm.yml b/.github/workflows/windows-arm.yml deleted file mode 100644 index 01c66e21..00000000 --- a/.github/workflows/windows-arm.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Windows-on-ARM - -on: - push: - branches: [ main ] - pull_request: - branches: - - main - - maintenance/** - -env: - OPENBLAS_ROOT: "c:\\opt" - # Preserve working directory for calls into bash - # Without this, invoking bash will cd to the home directory - CHERE_INVOKING: "yes" - BASH_PATH: "C:\\Program Files\\Git\\bin\\bash.exe" - PLAT: arm64 - -jobs: - build: - runs-on: windows-11-arm - timeout-minutes: 90 - - strategy: - matrix: - INTERFACE64: ['1', '0'] - - env: - INTERFACE64: ${{ matrix.INTERFACE64 }} - - steps: - - - uses: actions/checkout@v4.1.1 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - architecture: arm64 - - - name: Download and install LLVM installer - run: | - Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/LLVM-20.1.8-woa64.exe -UseBasicParsing -OutFile LLVM-woa64.exe - Start-Process -FilePath ".\LLVM-woa64.exe" -ArgumentList "/S" -Wait - echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - - name: Install CMake and Ninja for Win-ARM64 - shell: pwsh - run: | - Invoke-WebRequest https://github.com/Kitware/CMake/releases/download/v3.29.4/cmake-3.29.4-windows-arm64.msi -OutFile cmake-arm64.msi - Start-Process msiexec.exe -ArgumentList "/i cmake-arm64.msi /quiet /norestart" -Wait - echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH - - Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-winarm64.zip -OutFile ninja-winarm64.zip - Expand-Archive ninja-winarm64.zip -DestinationPath ninja - Copy-Item ninja\ninja.exe -Destination "C:\Windows\System32" - - - name: Set env variables - run: | - if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { - echo "INTERFACE_BITS=64" >> $env:GITHUB_ENV - } else { - echo "INTERFACE_BITS=32" >> $env:GITHUB_ENV - } - - - name: Build - run: | - git submodule update --init --recursive - .\tools\build_steps_win_arm64.bat 64 ${env:INTERFACE_BITS} - - - name: Test ${{ matrix.INTERFACE_BITS }}-bit interface wheel - run: | - python -m pip install --no-index --find-links dist scipy_openblas${env:INTERFACE_BITS} - python -m scipy_openblas${env:INTERFACE_BITS} - python -c "import scipy_openblas${env:INTERFACE_BITS}; print(scipy_openblas${env:INTERFACE_BITS}.get_pkg_config())" - - - uses: actions/upload-artifact@v4.3.0 - with: - name: wheels-${{ env.PLAT }}-${{ env.INTERFACE64 }} - path: dist/scipy_openblas*.whl - - - name: Install Anaconda client - run: | - # Rust installation needed for rpds-py. - Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -UseBasicParsing -Outfile rustup-init.exe - .\rustup-init.exe -y - $env:PATH="$env:PATH;$env:USERPROFILE\.cargo\bin" - pip install anaconda-client - - - name: Upload - # see https://github.com/marketplace/actions/setup-miniconda for why - # `-el {0}` is required. - shell: bash -el {0} - env: - ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }} - run: | - source tools/upload_to_anaconda_staging.sh - upload_wheels diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index bbd61d9c..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,180 +0,0 @@ -name: Win - -on: - push: - branches: [ main ] - pull_request: - branches: - - main - - maintenance/** - workflow_dispatch: null - -env: - OPENBLAS_ROOT: "c:\\opt" - # Preserve working directory for calls into bash - # Without this, invoking bash will cd to the home directory - CHERE_INVOKING: "yes" - BASH_PATH: "c:\\rtools40\\usr\\bin\\bash.exe" - -jobs: - build: - strategy: - matrix: - plat: ['x64', 'x86'] - INTERFACE64: ['1', '0'] - os: [windows-latest] - exclude: - - plat: x86 - INTERFACE64: '1' - fail-fast: false - runs-on: ${{ matrix.os }} - - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4.1.1 - - name: install-rtools - run: | - # rtools 42+ does not support 32 bits builds. - choco install -y rtools --no-progress --force --version=4.0.0.20220206 - - - name: Set env variables - run: | - echo "START_DIR=$PWD" >> $env:GITHUB_ENV - # For interpretation of MSYSTEM, see: - # https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939 - if ( "${{ matrix.plat }}" -eq "x86") { - echo "PLAT=i686" >> $env:GITHUB_ENV - echo "WHEEL_PLAT=win32" >> $env:GITHUB_ENV - echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV - # No ucrt on 32-bits, so use _snprintf_c instead - echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $env:GITHUB_ENV - echo "BUILD_BITS=32" >> $env:GITHUB_ENV - } else { - echo "PLAT=x86_64" >> $env:GITHUB_ENV - echo "WHEEL_PLAT=win_amd64" >> $env:GITHUB_ENV - echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV - echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV - echo "BUILD_BITS=64" >> $env:GITHUB_ENV - } - if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { - echo "INTERFACE64=1" >> $env:GITHUB_ENV - } - $CIBW = "${{ github.workspace }}/.openblas" - $CIBW = $CIBW.replace("\","/") - echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $env:GITHUB_ENV - - - name: Debug - run: | - echo CIBW_ENVIRONMENT_WINDOWS=$env:CIBW_ENVIRONMENT_WINDOWS - - - name: Build - run: | - git submodule update --init --recursive - & $env:BASH_PATH -lc tools/build_steps_windows.sh - - - name: Test - run: | - & $env:BASH_PATH -lc tools/build_gfortran.sh - echo "Static test" - .\for_test\test.exe - echo "Dynamic test" - .\for_test\test_dyn.exe - - - name: Copy - run: | - cp for_test\test*.exe builds - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - architecture: ${{ matrix.plat }} - - - - name: Build wheel - shell: bash - run: | - set -xeo pipefail - python -m pip install wheel - # This will fail if there is more than one file in libs - unzip -d local/scipy_openblas64 builds/openblas*.zip - if [[ -d local/scipy_openblas64/64 ]]; then - mv local/scipy_openblas64/64/* local/scipy_openblas64 - else - mv local/scipy_openblas64/32/* local/scipy_openblas64 - fi - mv local/scipy_openblas64/bin/*.dll local/scipy_openblas64/lib - rm local/scipy_openblas64/lib/*.a - rm -f local/scipy_openblas64/lib/*.exp # may not exist? - rm local/scipy_openblas64/lib/*.def - rm -rf local/scipy_openblas64/lib/pkgconfig - if [[ -d local/scipy_openblas64/64 ]]; then - rm -rf local/scipy_openblas64/64 - else - rm -rf local/scipy_openblas64/32 - fi - sed -e "s/bin/lib/" -i local/scipy_openblas64/lib/cmake/openblas/OpenBLASConfig.cmake - sed -e "s/dll/lib/" -i local/scipy_openblas64/lib/cmake/openblas/OpenBLASConfig.cmake - if [[ "${INTERFACE64}" != "1" ]]; then - mv local/scipy_openblas64 local/scipy_openblas32 - # rewrite the name of the project to scipy-openblas32 - # this is a hack, but apparently there is no other way to change the name - # of a pyproject.toml project - sed -e "s/openblas64/openblas32/" -i pyproject.toml - sed -e "s/openblas_get_config64_/openblas_get_config/" -i local/scipy_openblas32/__init__.py - sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i local/scipy_openblas32/__init__.py - sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__init__.py - sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__main__.py - fi - echo "" >> LICENSE.txt - echo "----" >> LICENSE.txt - echo "" >> LICENSE.txt - cat tools/LICENSE_win32.txt >> LICENSE.txt - python -m pip wheel -w dist -vv . - # move the mis-named scipy_openblas64-none-any.whl to a platform-specific name - if [[ -e dist/*any*.whl ]]; then - for f in dist/*.whl; do mv $f "${f/%any.whl/$WHEEL_PLAT.whl}"; done - fi - - - name: Set up different Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - architecture: ${{ matrix.plat }} - - - uses: actions/upload-artifact@v4.3.0 - with: - name: wheels-${{matrix.plat }}-${{ matrix.INTERFACE64 }} - path: dist/scipy_openblas*.whl - - - name: Test 64-bit interface wheel - if: matrix.INTERFACE64 == '1' - run: | - python -m pip install --no-index --find-links dist scipy_openblas64 - python -m scipy_openblas64 - python -c "import scipy_openblas64; print(scipy_openblas64.get_pkg_config())" - - - name: Test 32-bit interface wheel - if: matrix.INTERFACE64 != '1' - run: | - python -m pip install --no-index --find-links dist scipy_openblas32 - python -m scipy_openblas32 - python -c "import scipy_openblas32; print(scipy_openblas32.get_pkg_config())" - - - uses: conda-incubator/setup-miniconda@v3.1.1 - with: - channels: conda-forge - channel-priority: true - activate-environment: upload - miniforge-version: latest - - - name: Upload - # see https://github.com/marketplace/actions/setup-miniconda for why - # `-el {0}` is required. - shell: bash -el {0} - env: - ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }} - run: | - conda install -y anaconda-client - source tools/upload_to_anaconda_staging.sh - upload_wheels diff --git a/pyproject.toml b/pyproject.toml index c538cb82..19163976 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,9 +41,6 @@ install_requires = "importlib-metadata ~= 1.0 ; python_version < '3.8'" scipy_openblas64 = ["lib/*", "include/*", "lib/pkgconfig/*", "lib/cmake/openblas/*"] [tool.cibuildwheel] -before-build = "bash ci-before-build.sh" -repair-wheel-command = "bash ci-repair-wheel.sh {dest_dir} {wheel}" -test-command = "cd {package} && bash ci-test.sh" environment-pass = [ "OPENBLAS_COMMIT", "NIGHTLY", @@ -55,5 +52,21 @@ environment-pass = [ "OS-NAME", "RUNNER_ARCH", ] + [tool.cibuildwheel.linux] environment = { CC = "/opt/clang/bin/clang", CXX = "/opt/clang/bin/clang++", LDFLAGS = "-fuse-ld=lld" } +before-build = "bash ci-before-build.sh" +repair-wheel-command = "bash ci-repair-wheel.sh {dest_dir} {wheel}" +test-command = "cd {package} && bash ci-test.sh " +archs = ["x86_64", "aarch64", "i686", "ppc64le", "s390x"] + +[tool.cibuildwheel.macos] +before-build = "bash ci-before-build.sh" +repair-wheel-command = "bash ci-repair-wheel.sh {dest_dir} {wheel}" +test-command = "cd {package} && bash ci-test.sh" +archs = ["x86_64", "arm64"] + +[tool.cibuildwheel.windows] +repair-wheel-command = "bash tools\\repair_for_win.sh {dest_dir} {wheel}" +test-command = "bash {project}\\tools\\test_for_win.sh" +archs = ["AMD64", "x86", "ARM64"] \ No newline at end of file diff --git a/tools/build_steps_win_arm64.bat b/tools/build_steps_win_arm64.bat index 21c997c4..26c5b98b 100755 --- a/tools/build_steps_win_arm64.bat +++ b/tools/build_steps_win_arm64.bat @@ -174,39 +174,7 @@ cd ../.. :: Build the Wheel & Install It echo Running 'python -m build' to build the wheel... python -c "import build" 2>NUL || pip install build -if "%if_bits%"=="64" ( - python -m build - if errorlevel 1 exit /b 1 -) else ( +if "%if_bits%"=="32" ( move /Y pyproject.toml pyproject.toml.bak move /Y %out_pyproject% pyproject.toml - python -m build - if errorlevel 1 exit /b 1 - move /Y pyproject.toml.bak pyproject.toml -) -if "%if_bits%"=="32" ( - move /Y "%CD%\ob64_backup" "%ob_64%" -) - -:: Rename the wheel -for %%f in (dist\*any.whl) do ( - set WHEEL_FILE=dist\%%f - set "filename=%%~nxf" - set "newname=!filename:any.whl=win_arm64.whl!" - ren "dist\!filename!" "!newname!" -) - -:: Locate the built wheel -for /f %%f in ('dir /b dist\scipy_openblas*.whl 2^>nul') do set WHEEL_FILE=dist\%%f - -if not defined WHEEL_FILE ( - echo Error: No wheel file found in dist folder. - exit /b 1 -) - -echo Installing wheel: %WHEEL_FILE% -pip install "%WHEEL_FILE%" -if errorlevel 1 exit /b 1 - -echo Done. -exit /b 0 +) \ No newline at end of file diff --git a/tools/build_wheel_prepare_for_win.sh b/tools/build_wheel_prepare_for_win.sh new file mode 100644 index 00000000..b6a29387 --- /dev/null +++ b/tools/build_wheel_prepare_for_win.sh @@ -0,0 +1,36 @@ +set -xeo pipefail +python -m pip install wheel +# This will fail if there is more than one file in libs +unzip -d local/scipy_openblas64 builds/openblas*.zip +if [[ -d local/scipy_openblas64/64 ]]; then + mv local/scipy_openblas64/64/* local/scipy_openblas64 +else + mv local/scipy_openblas64/32/* local/scipy_openblas64 +fi +mv local/scipy_openblas64/bin/*.dll local/scipy_openblas64/lib +rm local/scipy_openblas64/lib/*.a +rm -f local/scipy_openblas64/lib/*.exp # may not exist? +rm local/scipy_openblas64/lib/*.def +rm -rf local/scipy_openblas64/lib/pkgconfig +if [[ -d local/scipy_openblas64/64 ]]; then + rm -rf local/scipy_openblas64/64 +else + rm -rf local/scipy_openblas64/32 +fi +sed -e "s/bin/lib/" -i local/scipy_openblas64/lib/cmake/openblas/OpenBLASConfig.cmake +sed -e "s/dll/lib/" -i local/scipy_openblas64/lib/cmake/openblas/OpenBLASConfig.cmake +if [[ "${INTERFACE64}" != "1" ]]; then + mv local/scipy_openblas64 local/scipy_openblas32 + # rewrite the name of the project to scipy-openblas32 + # this is a hack, but apparently there is no other way to change the name + # of a pyproject.toml project + sed -e "s/openblas64/openblas32/" -i pyproject.toml + sed -e "s/openblas_get_config64_/openblas_get_config/" -i local/scipy_openblas32/__init__.py + sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i local/scipy_openblas32/__init__.py + sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__init__.py + sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__main__.py +fi +echo "" >> LICENSE.txt +echo "----" >> LICENSE.txt +echo "" >> LICENSE.txt +cat tools/LICENSE_win32.txt >> LICENSE.txt \ No newline at end of file diff --git a/tools/repair_for_win.sh b/tools/repair_for_win.sh new file mode 100644 index 00000000..12ec4840 --- /dev/null +++ b/tools/repair_for_win.sh @@ -0,0 +1,14 @@ +set -xe +pip install delvewheel + +if [[ ${OSNAME} -eq "windows-latest" ]]; then + # Since it has the correct platform tag, we don't need to rename the wheel for windows-latest + # for f in dist/*.whl; + # do mv $f "${f/%any.whl/$WHEEL_PLAT.whl}"; + # done + delvewheel repair -w $1 $2 + exit 0 +fi + +# repair for windows arm64 +./tools/repair_for_win_arm64.bat $1 $2 \ No newline at end of file diff --git a/tools/repair_for_win_arm64.bat b/tools/repair_for_win_arm64.bat new file mode 100644 index 00000000..5a9f3e69 --- /dev/null +++ b/tools/repair_for_win_arm64.bat @@ -0,0 +1,14 @@ +if "%if_bits%"=="32" ( + move /Y pyproject.toml.bak pyproject.toml + move /Y "%CD%\ob64_backup" "%ob_64%" +) + +delvewheel repair -w %1 %2 + +:: Rename the wheel +@REM for %%f in (dist\*any.whl) do ( +@REM set WHEEL_FILE=dist\%%f +@REM set "filename=%%~nxf" +@REM set "newname=!filename:any.whl=win_arm64.whl!" +@REM ren "dist\!filename!" "!newname!" +@REM ) \ No newline at end of file diff --git a/tools/test_for_win.sh b/tools/test_for_win.sh new file mode 100644 index 00000000..b6ab3afd --- /dev/null +++ b/tools/test_for_win.sh @@ -0,0 +1,9 @@ +if [[ "${INTERFACE64}" == "1" ]]; then + # python -m pip install --no-index --find-links dist scipy_openblas64 + python -m scipy_openblas64 + python -c "import scipy_openblas64; print(scipy_openblas64.get_pkg_config())" +else + # python -m pip install --no-index --find-links dist scipy_openblas32 + python -m scipy_openblas32 + python -c "import scipy_openblas32; print(scipy_openblas32.get_pkg_config())" +fi \ No newline at end of file From 0417a488f089d339bd9a897da13b7f428a242348 Mon Sep 17 00:00:00 2001 From: ffgan Date: Fri, 19 Dec 2025 22:01:01 +0800 Subject: [PATCH 2/2] Add the missing conditional statement Co-authored by: nijincheng@iscas.ac.cn; Signed-off-by: ffgan --- .github/workflows/posix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index 3001eeb0..3ef6316e 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -214,6 +214,7 @@ jobs: cp for_test\test*.exe builds - name: prepare wheel + if: ${{ matrix.os == 'windows-latest' }} run: | ./tools/build_wheel_prepare_for_win.sh