|
| 1 | +name: Python Build Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master"] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build_wheels: |
| 9 | + name: Build wheels on ${{ matrix.os }} |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + #os: [ubuntu-latest, windows-latest, macos-13, macos-14] |
| 14 | + #os: [ubuntu-latest, macos-13, macos-14] |
| 15 | + os: [ubuntu-latest, macos-13] # For now build for ubuntu and mac-os x64 |
| 16 | + #os: [ubuntu-latest] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Install build tools (Linux) |
| 24 | + if: runner.os == 'Linux' |
| 25 | + run: | |
| 26 | + sudo apt-get update |
| 27 | + sudo apt-get install -y gfortran g++ cmake make |
| 28 | +
|
| 29 | + # - name: Install build tools (Windows) |
| 30 | + # if: runner.os == 'Windows' |
| 31 | + # run: | |
| 32 | + # choco install mingw -y |
| 33 | + # echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" >> $env:GITHUB_PATH |
| 34 | + |
| 35 | + - name: Install conda (macOS) |
| 36 | + if: runner.os == 'macOS' |
| 37 | + uses: conda-incubator/setup-miniconda@v2 |
| 38 | + with: |
| 39 | + miniforge-version: "latest" |
| 40 | + activate-environment: buildenv |
| 41 | + environment-file: "" |
| 42 | + auto-activate-base: false |
| 43 | + |
| 44 | + - name: Install buildtools (macOS) |
| 45 | + if: runner.os == 'macOS' |
| 46 | + run: | |
| 47 | + conda install -n buildenv -c conda-forge gfortran=11 libgfortran=5 cmake clang libgcc libgfortran5 libcxx |
| 48 | + echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV |
| 49 | + echo "$CONDA_PREFIX/bin" >> $GITHUB_PATH |
| 50 | + echo "DYLD_FALLBACK_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV |
| 51 | + shell: bash -l {0} |
| 52 | + |
| 53 | + - name: Check build tools |
| 54 | + run: | |
| 55 | + which cmake |
| 56 | + cmake --version |
| 57 | + which gfortran |
| 58 | + gfortran --version |
| 59 | + which clang++ |
| 60 | + clang++ --version |
| 61 | + which make |
| 62 | + make --version |
| 63 | + echo $PATH |
| 64 | + echo $PWD |
| 65 | + git rev-parse HEAD |
| 66 | +
|
| 67 | + - name: Build wheels (macOS) |
| 68 | + if: runner.os == 'macOS' |
| 69 | + uses: pypa/cibuildwheel@v3.0.1 |
| 70 | + env: |
| 71 | + MACOSX_DEPLOYMENT_TARGET: "10.15" |
| 72 | + # LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }} |
| 73 | + #SDKROOT: $(xcrun --sdk macosx --show-sdk-path) |
| 74 | + CIBW_BEFORE_BUILD: | |
| 75 | + SDKROOT=$(xcrun --sdk macosx --show-sdk-path) |
| 76 | + echo "SDKROOT=$SDKROOT" |
| 77 | + export SDKROOT |
| 78 | + echo "Adjusting PATH" |
| 79 | + export PATH="/usr/bin:/usr/local/bin:$PATH" |
| 80 | + which make |
| 81 | + which clang++ |
| 82 | + which gfortran |
| 83 | + clang++ --version |
| 84 | + gfortran --version |
| 85 | + DYLD_FALLBACK_LIBRARY_PATH=${{ env.DYLD_FALLBACK_LIBRARY_PATH }} |
| 86 | + export DYLD_FALLBACK_LIBRARY_PATH |
| 87 | + echo "DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH" |
| 88 | + CIBW_ENVIRONMENT: > |
| 89 | + PATH="/usr/bin:/usr/local/bin:$PATH" |
| 90 | + MACOSX_DEPLOYMENT_TARGET=10.15 |
| 91 | + SDKROOT=$(xcrun --sdk macosx --show-sdk-path) |
| 92 | + with: |
| 93 | + package-dir: . |
| 94 | + output-dir: wheelhouse |
| 95 | + config-file: "{package}/pyproject.toml" |
| 96 | + |
| 97 | + - name: Build wheels (Linux) |
| 98 | + if: runner.os == 'Linux' |
| 99 | + uses: pypa/cibuildwheel@v3.0.1 |
| 100 | + with: |
| 101 | + package-dir: . |
| 102 | + output-dir: wheelhouse |
| 103 | + config-file: "{package}/pyproject.toml" |
| 104 | + |
| 105 | + # - name: Re-tag wheels for Python3.x |
| 106 | + # run: | |
| 107 | + # pip install wheel-fix |
| 108 | + # for whl in wheelhouse/*.whl; do |
| 109 | + # wheel-fix --python-tag py3 --abi-tag none "$whl" |
| 110 | + # done |
| 111 | + |
| 112 | + - uses: actions/upload-artifact@v4 |
| 113 | + with: |
| 114 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 115 | + path: ./wheelhouse/*.whl |
| 116 | + |
| 117 | + make_sdist: |
| 118 | + name: Make Python sdist |
| 119 | + runs-on: ubuntu-latest |
| 120 | + steps: |
| 121 | + - uses: actions/checkout@v4 |
| 122 | + with: |
| 123 | + fetch-depth: 0 |
| 124 | + |
| 125 | + - name: Build sdist |
| 126 | + run: pipx run build --sdist |
| 127 | + |
| 128 | + - uses: actions/upload-artifact@v4 |
| 129 | + with: |
| 130 | + name: cibw-sdist |
| 131 | + path: dist/*.tar.gz |
| 132 | + |
| 133 | + upload_to_index: |
| 134 | + name: Upload to PyPI index |
| 135 | + needs: [build_wheels, make_sdist] |
| 136 | + environment: pypi |
| 137 | + |
| 138 | + permissions: |
| 139 | + id-token: write |
| 140 | + attestations: write |
| 141 | + contents: read |
| 142 | + |
| 143 | + runs-on: ubuntu-latest |
| 144 | + # if: github.event_name == 'release' && github.event.action == 'published' |
| 145 | + steps: |
| 146 | + - uses: actions/download-artifact@v4 |
| 147 | + with: |
| 148 | + pattern: cibw-* |
| 149 | + path: dist |
| 150 | + merge-multiple: true |
| 151 | + |
| 152 | + - name: Generate attestations |
| 153 | + uses: actions/attest-build-provenance@v2 |
| 154 | + with: |
| 155 | + subject-path: "dist/*" |
| 156 | + |
| 157 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
| 158 | + with: |
| 159 | + # password: ${{ secrets.pypi_password }} |
| 160 | + # repository-url: "https://pypi.org/legacy" |
| 161 | + verbose: true |
| 162 | + skip-existing: true |
| 163 | + # attestations: false |
| 164 | + |
0 commit comments