|
| 1 | +name: Build Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "quaddtype-v*" |
| 9 | + paths: |
| 10 | + - "quaddtype/**" |
| 11 | + pull_request: |
| 12 | + paths: |
| 13 | + - "quaddtype/**" |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build_wheels_linux: |
| 18 | + name: Build wheels on Linux |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - name: Set up Python |
| 24 | + uses: actions/setup-python@v4 |
| 25 | + with: |
| 26 | + python-version: ">=3.10.0" |
| 27 | + |
| 28 | + - name: Install cibuildwheel |
| 29 | + run: pip install cibuildwheel==2.20.0 |
| 30 | + |
| 31 | + - name: Build wheels |
| 32 | + env: |
| 33 | + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" |
| 34 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 |
| 35 | + CIBW_BUILD_VERBOSITY: "3" |
| 36 | + CIBW_BEFORE_ALL: | |
| 37 | + git clone --branch 3.8 https://github.com/shibatch/sleef.git |
| 38 | + cd sleef |
| 39 | + cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 40 | + cmake --build build/ --clean-first -j |
| 41 | + cmake --install build --prefix /usr/local |
| 42 | + CIBW_ENVIRONMENT: > |
| 43 | + CFLAGS="-I/usr/local/include $CFLAGS" |
| 44 | + CXXFLAGS="-I/usr/local/include $CXXFLAGS" |
| 45 | + LDFLAGS="-L/usr/local/lib64 $LDFLAGS" |
| 46 | + LD_LIBRARY_PATH="/usr/local/lib64:$LD_LIBRARY_PATH" |
| 47 | + CIBW_REPAIR_WHEEL_COMMAND: | |
| 48 | + auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} |
| 49 | + CIBW_TEST_COMMAND: | |
| 50 | + pip install {package}[test] |
| 51 | + pytest -s {project}/tests |
| 52 | + CIBW_TEST_EXTRAS: "test" |
| 53 | + run: | |
| 54 | + python -m cibuildwheel --output-dir wheelhouse |
| 55 | + working-directory: ./quaddtype |
| 56 | + |
| 57 | + - uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + path: ./quaddtype/wheelhouse/*.whl |
| 60 | + name: wheels-linux |
| 61 | + |
| 62 | + build_wheels_macos: |
| 63 | + name: Build wheels on ${{ matrix.os }} |
| 64 | + runs-on: ${{ matrix.os }} |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + os: [macos-13, macos-14] |
| 68 | + |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v3 |
| 71 | + |
| 72 | + - name: Set up Python |
| 73 | + uses: actions/setup-python@v4 |
| 74 | + with: |
| 75 | + python-version: "3.10" |
| 76 | + |
| 77 | + - name: Install SLEEF |
| 78 | + env: |
| 79 | + MACOSX_DEPLOYMENT_TARGET: "11.0" |
| 80 | + run: | |
| 81 | + git clone --branch 3.8 https://github.com/shibatch/sleef.git |
| 82 | + cd sleef |
| 83 | + cmake -S . -B build \ |
| 84 | + -DSLEEF_BUILD_QUAD:BOOL=ON \ |
| 85 | + -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \ |
| 86 | + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
| 87 | + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ |
| 88 | + -DCMAKE_INSTALL_RPATH="@loader_path/../lib" \ |
| 89 | + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON |
| 90 | + cmake --build build/ --clean-first -j |
| 91 | + sudo cmake --install build --prefix /usr/local |
| 92 | + - name: Install cibuildwheel |
| 93 | + run: pip install cibuildwheel==2.20.0 |
| 94 | + |
| 95 | + - name: Build wheels |
| 96 | + env: |
| 97 | + CIBW_BUILD: "cp310-* cp311-* cp312-*" |
| 98 | + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} |
| 99 | + CIBW_BUILD_VERBOSITY: "1" |
| 100 | + CIBW_ENVIRONMENT: > |
| 101 | + MACOSX_DEPLOYMENT_TARGET="11.0" |
| 102 | + DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" |
| 103 | + CFLAGS="-I/usr/local/include $CFLAGS" |
| 104 | + CXXFLAGS="-I/usr/local/include $CXXFLAGS" |
| 105 | + LDFLAGS="-L/usr/local/lib $LDFLAGS" |
| 106 | + CIBW_REPAIR_WHEEL_COMMAND: > |
| 107 | + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} |
| 108 | + CIBW_TEST_COMMAND: | |
| 109 | + pip install {package}[test] |
| 110 | + pytest {project}/tests |
| 111 | + CIBW_TEST_EXTRAS: "test" |
| 112 | + run: | |
| 113 | + python -m cibuildwheel --output-dir wheelhouse |
| 114 | + working-directory: ./quaddtype |
| 115 | + |
| 116 | + - uses: actions/upload-artifact@v4 |
| 117 | + with: |
| 118 | + path: ./quaddtype/wheelhouse/*.whl |
| 119 | + name: wheels-${{ matrix.os }} |
| 120 | + |
| 121 | + build_wheels_windows: |
| 122 | + name: Build wheels on Windows |
| 123 | + runs-on: windows-latest |
| 124 | + strategy: |
| 125 | + matrix: |
| 126 | + architecture: [x64] |
| 127 | + |
| 128 | + steps: |
| 129 | + - uses: actions/checkout@v3 |
| 130 | + |
| 131 | + - name: Setup MSVC |
| 132 | + uses: ilammy/msvc-dev-cmd@v1 |
| 133 | + with: |
| 134 | + arch: ${{ matrix.architecture }} |
| 135 | + |
| 136 | + - name: Set up Python 3.10 |
| 137 | + uses: actions/setup-python@v4 |
| 138 | + with: |
| 139 | + python-version: "3.10" |
| 140 | + architecture: ${{ matrix.architecture }} |
| 141 | + |
| 142 | + - name: Install CMake |
| 143 | + uses: lukka/get-cmake@latest |
| 144 | + |
| 145 | + - name: Clone and Build SLEEF |
| 146 | + shell: pwsh |
| 147 | + run: | |
| 148 | + git clone --branch 3.8 https://github.com/shibatch/sleef.git |
| 149 | + cd sleef |
| 150 | + cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture == 'x86' && 'Win32' || 'x64' }} -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 151 | + cmake --build build --config Release --parallel |
| 152 | + cmake --install build --prefix "C:/sleef" --config Release |
| 153 | +
|
| 154 | + - name: Setup build environment |
| 155 | + shell: pwsh |
| 156 | + run: | |
| 157 | + $env:INCLUDE += ";C:\sleef\include" |
| 158 | + $env:LIB += ";C:\sleef\lib" |
| 159 | + $env:PATH = "C:\sleef\bin;$env:PATH" |
| 160 | + echo "INCLUDE=$env:INCLUDE" >> $env:GITHUB_ENV |
| 161 | + echo "LIB=$env:LIB" >> $env:GITHUB_ENV |
| 162 | + echo "PATH=$env:PATH" >> $env:GITHUB_ENV |
| 163 | +
|
| 164 | + - name: Install build dependencies |
| 165 | + shell: bash -l {0} |
| 166 | + run: | |
| 167 | + pip install -U pip |
| 168 | + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest |
| 169 | +
|
| 170 | + - name: Build wheels |
| 171 | + env: |
| 172 | + CIBW_BUILD: "cp310-* cp311-* cp312-*" |
| 173 | + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" |
| 174 | + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} |
| 175 | + CIBW_BUILD_VERBOSITY: "3" |
| 176 | + DISTUTILS_USE_SDK: "1" |
| 177 | + MSSdk: "1" |
| 178 | + CIBW_BEFORE_BUILD: | |
| 179 | + pip install meson meson-python ninja numpy |
| 180 | + CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin' |
| 181 | + CIBW_TEST_COMMAND: | |
| 182 | + pip install {package}[test] |
| 183 | + python -m pytest -v {project}/test |
| 184 | + CIBW_TEST_EXTRAS: test |
| 185 | + CIBW_TEST_FAIL_FAST: 1 |
| 186 | + shell: pwsh |
| 187 | + run: | |
| 188 | + python -m cibuildwheel --output-dir wheelhouse |
| 189 | + if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } |
| 190 | + working-directory: ./quaddtype |
| 191 | + |
| 192 | + - uses: actions/upload-artifact@v4 |
| 193 | + with: |
| 194 | + path: ./quaddtype/wheelhouse/*.whl |
| 195 | + name: wheels-windows-${{ matrix.architecture }} |
| 196 | + |
| 197 | + publish_to_testpypi: |
| 198 | + name: Publish to TestPyPI |
| 199 | + needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] |
| 200 | + runs-on: ubuntu-latest |
| 201 | + if: startsWith(github.ref, 'refs/tags/quaddtype-v') |
| 202 | + steps: |
| 203 | + - name: Download all workflow run artifacts |
| 204 | + uses: actions/download-artifact@v4 |
| 205 | + with: |
| 206 | + path: dist |
| 207 | + - name: Publish to TestPyPI |
| 208 | + |
| 209 | + with: |
| 210 | + user: __token__ |
| 211 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 212 | + repository-url: https://test.pypi.org/legacy/ |
| 213 | + packages-dir: dist/* |
| 214 | + |
| 215 | + create_release: |
| 216 | + name: Create Release |
| 217 | + needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] |
| 218 | + runs-on: ubuntu-latest |
| 219 | + if: startsWith(github.ref, 'refs/tags/quaddtype-v') |
| 220 | + |
| 221 | + steps: |
| 222 | + - name: Checkout code |
| 223 | + uses: actions/checkout@v2 |
| 224 | + |
| 225 | + - name: Download all workflow run artifacts |
| 226 | + uses: actions/download-artifact@v4 |
| 227 | + with: |
| 228 | + path: artifacts |
| 229 | + |
| 230 | + - name: Create Release |
| 231 | + id: create_release |
| 232 | + uses: actions/create-release@v1 |
| 233 | + env: |
| 234 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 235 | + with: |
| 236 | + tag_name: ${{ github.ref }} |
| 237 | + release_name: Release ${{ github.ref }} |
| 238 | + draft: false |
| 239 | + prerelease: false |
| 240 | + |
| 241 | + - name: Upload Release Assets |
| 242 | + uses: softprops/action-gh-release@v1 |
| 243 | + if: startsWith(github.ref, 'refs/tags/') |
| 244 | + with: |
| 245 | + files: ./artifacts/**/*.whl |
| 246 | + env: |
| 247 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
0 commit comments