|
| 1 | +name: Build Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - uni-workflow |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + pull_request: |
| 10 | + |
| 11 | +jobs: |
| 12 | + build_wheels_linux: |
| 13 | + name: Build wheels on Linux |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Set up Python |
| 19 | + uses: actions/setup-python@v4 |
| 20 | + with: |
| 21 | + python-version: ">=3.10.0" |
| 22 | + |
| 23 | + - name: Install cibuildwheel |
| 24 | + run: pip install cibuildwheel==2.20.0 |
| 25 | + |
| 26 | + - name: Build wheels |
| 27 | + env: |
| 28 | + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" |
| 29 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 |
| 30 | + CIBW_BUILD_VERBOSITY: "3" |
| 31 | + CIBW_BEFORE_ALL: | |
| 32 | + yum install -y wget |
| 33 | + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh |
| 34 | + bash miniconda.sh -b -p /root/miniconda |
| 35 | + export PATH="/root/miniconda/bin:$PATH" |
| 36 | + conda config --set always_yes yes --set changeps1 no |
| 37 | + conda update -q conda |
| 38 | + conda info -a |
| 39 | + conda config --add channels conda-forge |
| 40 | + conda config --set channel_priority strict |
| 41 | + conda create -n build_env python=3.10 |
| 42 | + source activate build_env |
| 43 | + conda install -y sleef |
| 44 | + CIBW_ENVIRONMENT: > |
| 45 | + LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" |
| 46 | + LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" |
| 47 | + CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" |
| 48 | + CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS" |
| 49 | + LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS" |
| 50 | + SLEEF_PATH="/root/miniconda/envs/build_env" |
| 51 | + CIBW_REPAIR_WHEEL_COMMAND: > |
| 52 | + auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} |
| 53 | + CIBW_TEST_COMMAND: | |
| 54 | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" |
| 55 | + python -c "import platform; print('Python version:', platform.python_version())" |
| 56 | + python -c "import sys; print('sys.platform:', sys.platform)" |
| 57 | + python -c "import quaddtype; print('quaddtype imported successfully')" |
| 58 | + pip install {package}[test] |
| 59 | + pytest {project}/tests |
| 60 | + CIBW_TEST_EXTRAS: "test" |
| 61 | + run: | |
| 62 | + python -m cibuildwheel --output-dir wheelhouse |
| 63 | + working-directory: ./quaddtype |
| 64 | + |
| 65 | + - uses: actions/upload-artifact@v3 |
| 66 | + with: |
| 67 | + path: ./quaddtype/wheelhouse/*.whl |
| 68 | + name: wheels-linux |
| 69 | + |
| 70 | + build_wheels_macos: |
| 71 | + name: Build wheels on ${{ matrix.os }} |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + os: [macos-13, macos-14] |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v3 |
| 79 | + |
| 80 | + - name: Set up Python |
| 81 | + uses: actions/setup-python@v4 |
| 82 | + with: |
| 83 | + python-version: ">=3.10.0" |
| 84 | + |
| 85 | + - name: Setup Miniconda |
| 86 | + uses: conda-incubator/setup-miniconda@v3 |
| 87 | + with: |
| 88 | + auto-update-conda: true |
| 89 | + python-version: "3.10" |
| 90 | + channels: conda-forge |
| 91 | + |
| 92 | + - name: Install SLEEF |
| 93 | + shell: bash -l {0} |
| 94 | + run: | |
| 95 | + conda install -y -c conda-forge sleef |
| 96 | + echo $CONDA_PREFIX |
| 97 | + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV |
| 98 | +
|
| 99 | + - name: Install cibuildwheel |
| 100 | + run: pip install cibuildwheel==2.20.0 |
| 101 | + |
| 102 | + - name: Build wheels |
| 103 | + env: |
| 104 | + CIBW_BUILD_VERBOSITY: "1" |
| 105 | + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} |
| 106 | + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" |
| 107 | + CIBW_ENVIRONMENT: > |
| 108 | + SLEEF_PATH="${{ env.SLEEF_PATH }}" |
| 109 | + DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" |
| 110 | + LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" |
| 111 | + CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" |
| 112 | + CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" |
| 113 | + LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" |
| 114 | + MACOSX_DEPLOYMENT_TARGET="10.13" |
| 115 | + CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" |
| 116 | + CIBW_TEST_COMMAND: | |
| 117 | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" |
| 118 | + python -c "import platform; print('Python version:', platform.python_version())" |
| 119 | + python -c "import sys; print('sys.platform:', sys.platform)" |
| 120 | + python -c "import quaddtype; print('quaddtype imported successfully')" |
| 121 | + pip install {package}[test] |
| 122 | + pytest {project}/tests |
| 123 | + CIBW_TEST_EXTRAS: "test" |
| 124 | + run: | |
| 125 | + echo "SLEEF_PATH: $SLEEF_PATH" |
| 126 | + ls $SLEEF_PATH/include/sleef* |
| 127 | + echo "PATH: $PATH" |
| 128 | + which python |
| 129 | + python --version |
| 130 | + which pip |
| 131 | + pip --version |
| 132 | + cd quaddtype |
| 133 | + python -m cibuildwheel --output-dir wheelhouse |
| 134 | +
|
| 135 | + - uses: actions/upload-artifact@v3 |
| 136 | + with: |
| 137 | + path: ./quaddtype/wheelhouse/*.whl |
| 138 | + name: wheels-${{ matrix.os }} |
| 139 | + |
| 140 | + build_wheels_windows: |
| 141 | + name: Build wheels on Windows |
| 142 | + runs-on: windows-latest |
| 143 | + strategy: |
| 144 | + matrix: |
| 145 | + architecture: [x64] |
| 146 | + |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@v3 |
| 149 | + |
| 150 | + - name: Setup MSVC |
| 151 | + uses: ilammy/msvc-dev-cmd@v1 |
| 152 | + with: |
| 153 | + arch: ${{ matrix.architecture }} |
| 154 | + |
| 155 | + - name: Set up Python 3.10 |
| 156 | + uses: actions/setup-python@v4 |
| 157 | + with: |
| 158 | + python-version: "3.10" |
| 159 | + architecture: ${{ matrix.architecture }} |
| 160 | + |
| 161 | + - name: Install Miniconda |
| 162 | + uses: conda-incubator/setup-miniconda@v3 |
| 163 | + with: |
| 164 | + auto-update-conda: true |
| 165 | + python-version: "3.10" |
| 166 | + architecture: ${{ matrix.architecture }} |
| 167 | + |
| 168 | + - name: Install SLEEF and other dependencies |
| 169 | + shell: bash -l {0} |
| 170 | + run: | |
| 171 | + conda config --add channels conda-forge |
| 172 | + conda config --set channel_priority strict |
| 173 | + conda install -y sleef numpy |
| 174 | + conda list |
| 175 | + if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then |
| 176 | + echo "sleef.h not found. Installation may have failed." |
| 177 | + exit 1 |
| 178 | + fi |
| 179 | + ls -l "$CONDA_PREFIX/Library/include/sleef.h" |
| 180 | + ls -l "$CONDA_PREFIX/Library/lib/sleef"* |
| 181 | +
|
| 182 | + - name: Set environment variables |
| 183 | + shell: pwsh |
| 184 | + run: | |
| 185 | + echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 186 | + $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" |
| 187 | + echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 188 | +
|
| 189 | + - name: Install build dependencies |
| 190 | + shell: bash -l {0} |
| 191 | + run: | |
| 192 | + pip install -U pip |
| 193 | + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest |
| 194 | +
|
| 195 | + - name: Build wheels |
| 196 | + env: |
| 197 | + CONDA_PREFIX: ${{ env.CONDA_PREFIX }} |
| 198 | + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" |
| 199 | + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} |
| 200 | + CIBW_BUILD_VERBOSITY: "1" |
| 201 | + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include |
| 202 | + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib |
| 203 | + DISTUTILS_USE_SDK: "1" |
| 204 | + MSSdk: "1" |
| 205 | + NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} |
| 206 | + CIBW_ENVIRONMENT: >- |
| 207 | + NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" |
| 208 | + SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include" |
| 209 | + SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib" |
| 210 | + CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy |
| 211 | + CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" |
| 212 | + CIBW_TEST_COMMAND: | |
| 213 | + python -c "import platform; print('Python version:', platform.python_version())" |
| 214 | + python -c "import sys; print('sys.platform:', sys.platform)" |
| 215 | + python -c "import quaddtype; print('quaddtype imported successfully')" |
| 216 | + pip install {package}[test] |
| 217 | + pytest {project}\tests -v || (echo "Tests failed" && exit 1) |
| 218 | + CIBW_TEST_EXTRAS: "test" |
| 219 | + CIBW_TEST_FAIL_FAST: 1 |
| 220 | + shell: pwsh |
| 221 | + run: | |
| 222 | + python -m cibuildwheel --output-dir wheelhouse |
| 223 | + if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } |
| 224 | + working-directory: ./quaddtype |
| 225 | + |
| 226 | + - uses: actions/upload-artifact@v3 |
| 227 | + with: |
| 228 | + path: ./quaddtype/wheelhouse/*.whl |
| 229 | + name: wheels-windows-${{ matrix.architecture }} |
| 230 | + |
| 231 | + publish_to_testpypi: |
| 232 | + name: Publish to TestPyPI |
| 233 | + needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] |
| 234 | + runs-on: ubuntu-latest |
| 235 | + if: startsWith(github.ref, 'refs/tags/') |
| 236 | + steps: |
| 237 | + - name: Download all workflow run artifacts |
| 238 | + uses: actions/download-artifact@v2 |
| 239 | + with: |
| 240 | + path: dist |
| 241 | + - name: Publish to TestPyPI |
| 242 | + uses: pypa/gh-action-pypi-publish@v1.9.0 |
| 243 | + with: |
| 244 | + user: __token__ |
| 245 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 246 | + repository-url: https://test.pypi.org/legacy/ |
| 247 | + packages-dir: dist/* |
| 248 | + |
| 249 | + create_release: |
| 250 | + name: Create Release |
| 251 | + needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] |
| 252 | + runs-on: ubuntu-latest |
| 253 | + if: startsWith(github.ref, 'refs/tags/') |
| 254 | + |
| 255 | + steps: |
| 256 | + - name: Checkout code |
| 257 | + uses: actions/checkout@v2 |
| 258 | + |
| 259 | + - name: Download all workflow run artifacts |
| 260 | + uses: actions/download-artifact@v2 |
| 261 | + with: |
| 262 | + path: artifacts |
| 263 | + |
| 264 | + - name: Create Release |
| 265 | + id: create_release |
| 266 | + uses: actions/create-release@v1 |
| 267 | + env: |
| 268 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 269 | + with: |
| 270 | + tag_name: ${{ github.ref }} |
| 271 | + release_name: Release ${{ github.ref }} |
| 272 | + draft: false |
| 273 | + prerelease: false |
| 274 | + |
| 275 | + - name: Upload Release Assets |
| 276 | + uses: softprops/action-gh-release@v1 |
| 277 | + if: startsWith(github.ref, 'refs/tags/') |
| 278 | + with: |
| 279 | + files: ./artifacts/**/*.whl |
| 280 | + env: |
| 281 | + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
0 commit comments