|
| 1 | +name: Win |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: null |
| 9 | + |
| 10 | +env: |
| 11 | + OPENBLAS_COMMIT: "v0.3.29" |
| 12 | + OPENBLAS_ROOT: "c:\\opt" |
| 13 | + # Preserve working directory for calls into bash |
| 14 | + # Without this, invoking bash will cd to the home directory |
| 15 | + CHERE_INVOKING: "yes" |
| 16 | + BASH_PATH: "c:\\rtools40\\usr\\bin\\bash.exe" |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + plat: ['x64', 'x86'] |
| 23 | + INTERFACE64: ['1', '0'] |
| 24 | + os: [windows-latest] |
| 25 | + exclude: |
| 26 | + - plat: x86 |
| 27 | + INTERFACE64: '1' |
| 28 | + fail-fast: false |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + |
| 31 | + timeout-minutes: 90 |
| 32 | + steps: |
| 33 | + |
| 34 | + - name: install-rtools |
| 35 | + run: | |
| 36 | + # rtools 42+ does not support 32 bits builds. |
| 37 | + choco install -y rtools --no-progress --force --version=4.0.0.20220206 |
| 38 | +
|
| 39 | + - name: Set env variables |
| 40 | + run: | |
| 41 | + echo "START_DIR=$PWD" >> $env:GITHUB_ENV |
| 42 | + # For interpretation of MSYSTEM, see: |
| 43 | + # https://sourceforge.net/p/msys2/discussion/general/thread/b7dfdac8/#3939 |
| 44 | + if ( "${{ matrix.plat }}" -eq "x86") { |
| 45 | + echo "PLAT=i686" >> $env:GITHUB_ENV |
| 46 | + echo "WHEEL_PLAT=win32" >> $env:GITHUB_ENV |
| 47 | + echo "MSYSTEM=MINGW32" >> $env:GITHUB_ENV |
| 48 | + # No ucrt on 32-bits, so use _snprintf_c instead |
| 49 | + echo "LDFLAGS=-static -static-libgcc -Wl,--defsym,_quadmath_snprintf=__snprintf_c" >> $env:GITHUB_ENV |
| 50 | + echo "BUILD_BITS=32" >> $env:GITHUB_ENV |
| 51 | + } else { |
| 52 | + echo "PLAT=x86_64" >> $env:GITHUB_ENV |
| 53 | + echo "WHEEL_PLAT=win_amd64" >> $env:GITHUB_ENV |
| 54 | + echo "MSYSTEM=UCRT64" >> $env:GITHUB_ENV |
| 55 | + echo "LDFLAGS=-lucrt -static -static-libgcc -Wl,--defsym,quadmath_snprintf=snprintf" >> $env:GITHUB_ENV |
| 56 | + echo "BUILD_BITS=64" >> $env:GITHUB_ENV |
| 57 | + } |
| 58 | + if ( ${{ matrix.INTERFACE64 }} -eq "1" ) { |
| 59 | + echo "INTERFACE64=1" >> $env:GITHUB_ENV |
| 60 | + } |
| 61 | + $CIBW = "${{ github.workspace }}/.openblas" |
| 62 | + $CIBW = $CIBW.replace("\","/") |
| 63 | + echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $env:GITHUB_ENV |
| 64 | +
|
| 65 | + - name: Debug |
| 66 | + run: | |
| 67 | + echo CIBW_ENVIRONMENT_WINDOWS=$env:CIBW_ENVIRONMENT_WINDOWS |
| 68 | +
|
| 69 | + - name: Build |
| 70 | + run: | |
| 71 | + git submodule update --init --recursive |
| 72 | + & $env:BASH_PATH -lc tools/build_openblas.sh |
| 73 | +
|
| 74 | + - name: Test |
| 75 | + run: | |
| 76 | + & $env:BASH_PATH -lc tools/build_gfortran.sh |
| 77 | + echo "Static test" |
| 78 | + .\for_test\test.exe |
| 79 | + echo "Dynamic test" |
| 80 | + .\for_test\test_dyn.exe |
| 81 | +
|
| 82 | + - name: Copy |
| 83 | + run: | |
| 84 | + cp for_test\test*.exe builds |
| 85 | +
|
| 86 | + - name: Set up Python |
| 87 | + uses: actions/setup-python@v5 |
| 88 | + with: |
| 89 | + python-version: 3.9 |
| 90 | + architecture: ${{ matrix.plat }} |
| 91 | + |
| 92 | + |
| 93 | + - name: Build wheel |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + set -xeo pipefail |
| 97 | + python -m pip install wheel |
| 98 | + # This will fail if there is more than one file in libs |
| 99 | + unzip -d local/scipy_openblas64 builds/openblas*.zip |
| 100 | + if [[ -d local/scipy_openblas64/64 ]]; then |
| 101 | + mv local/scipy_openblas64/64/* local/scipy_openblas64 |
| 102 | + else |
| 103 | + mv local/scipy_openblas64/32/* local/scipy_openblas64 |
| 104 | + fi |
| 105 | + mv local/scipy_openblas64/bin/*.dll local/scipy_openblas64/lib |
| 106 | + rm local/scipy_openblas64/lib/*.a |
| 107 | + rm -f local/scipy_openblas64/lib/*.exp # may not exist? |
| 108 | + rm local/scipy_openblas64/lib/*.def |
| 109 | + rm -rf local/scipy_openblas64/lib/pkgconfig |
| 110 | + if [[ -d local/scipy_openblas64/64 ]]; then |
| 111 | + rm -rf local/scipy_openblas64/64 |
| 112 | + else |
| 113 | + rm -rf local/scipy_openblas64/32 |
| 114 | + fi |
| 115 | + if [[ "${INTERFACE64}" != "1" ]]; then |
| 116 | + mv local/scipy_openblas64 local/scipy_openblas32 |
| 117 | + # rewrite the name of the project to scipy-openblas32 |
| 118 | + # this is a hack, but apparently there is no other way to change the name |
| 119 | + # of a pyproject.toml project |
| 120 | + sed -e "s/openblas64/openblas32/" -i pyproject.toml |
| 121 | + sed -e "s/openblas_get_config64_/openblas_get_config/" -i local/scipy_openblas32/__init__.py |
| 122 | + sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i local/scipy_openblas32/__init__.py |
| 123 | + sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__init__.py |
| 124 | + sed -e "s/openblas64/openblas32/" -i local/scipy_openblas32/__main__.py |
| 125 | + fi |
| 126 | + echo "" >> LICENSE.txt |
| 127 | + echo "----" >> LICENSE.txt |
| 128 | + echo "" >> LICENSE.txt |
| 129 | + cat tools/LICENSE_win32.txt >> LICENSE.txt |
| 130 | + python -m pip wheel -w dist -vv . |
| 131 | + # move the mis-named scipy_openblas64-none-any.whl to a platform-specific name |
| 132 | + for f in dist/*.whl; do mv $f "${f/%any.whl/$WHEEL_PLAT.whl}"; done |
| 133 | +
|
| 134 | + - name: Set up different Python |
| 135 | + uses: actions/setup-python@v5 |
| 136 | + with: |
| 137 | + python-version: 3.11 |
| 138 | + architecture: ${{ matrix.plat }} |
| 139 | + |
| 140 | + |
| 141 | + with: |
| 142 | + name: wheels-${{matrix.plat }}-${{ matrix.INTERFACE64 }} |
| 143 | + path: dist/scipy_openblas*.whl |
| 144 | + |
| 145 | + |
| 146 | + with: |
| 147 | + name: openblas-${{matrix.plat }}-${{ matrix.INTERFACE64 }} |
| 148 | + path: builds/openblas*.zip |
| 149 | + |
| 150 | + - name: Test 64-bit interface wheel |
| 151 | + if: matrix.INTERFACE64 == '1' |
| 152 | + run: | |
| 153 | + python -m pip install --no-index --find-links dist scipy_openblas64 |
| 154 | + python -m scipy_openblas64 |
| 155 | + python -c "import scipy_openblas64; print(scipy_openblas64.get_pkg_config())" |
| 156 | +
|
| 157 | + - name: Test 32-bit interface wheel |
| 158 | + if: matrix.INTERFACE64 != '1' |
| 159 | + run: | |
| 160 | + python -m pip install --no-index --find-links dist scipy_openblas32 |
| 161 | + python -m scipy_openblas32 |
| 162 | + python -c "import scipy_openblas32; print(scipy_openblas32.get_pkg_config())" |
| 163 | +
|
| 164 | + - uses: conda-incubator/[email protected] |
| 165 | + with: |
| 166 | + channels: conda-forge |
| 167 | + channel-priority: true |
| 168 | + activate-environment: upload |
| 169 | + miniforge-version: latest |
| 170 | + |
| 171 | + - name: Upload |
| 172 | + # see https://github.com/marketplace/actions/setup-miniconda for why |
| 173 | + # `-el {0}` is required. |
| 174 | + shell: bash -el {0} |
| 175 | + env: |
| 176 | + ANACONDA_SCIENTIFIC_PYTHON_UPLOAD: ${{ secrets.ANACONDA_SCIENTIFIC_PYTHON_UPLOAD }} |
| 177 | + run: | |
| 178 | + conda install -y anaconda-client |
| 179 | + source tools/upload_to_anaconda_staging.sh |
| 180 | + upload_wheels |
0 commit comments