|
| 1 | +# pythonocc-core wheels for PyPI: Linux x86_64/aarch64, macOS x86_64/arm64, |
| 2 | +# Windows AMD64, for CPython 3.10 to 3.14, plus the sdist. |
| 3 | +# |
| 4 | +# For each platform, a first job builds the native dependencies (SWIG, OCCT |
| 5 | +# and its 3rd parties) with the scripts of ci/wheels/deps/ and saves them to |
| 6 | +# the GitHub cache, then one job per Python version restores them and runs |
| 7 | +# cibuildwheel (configured in pyproject.toml). Pushing a tag also uploads |
| 8 | +# the wheels and the sdist to PyPI, through trusted publishing. |
| 9 | + |
| 10 | +name: Wheels |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: ["master", "review/**"] |
| 15 | + # the paths filter does not apply to the tags |
| 16 | + tags: ["*"] |
| 17 | + paths: |
| 18 | + - pyproject.toml |
| 19 | + - CMakeLists.txt |
| 20 | + - ci/wheels/** |
| 21 | + - .github/workflows/wheels.yml |
| 22 | + pull_request: |
| 23 | + paths: |
| 24 | + - pyproject.toml |
| 25 | + - CMakeLists.txt |
| 26 | + - ci/wheels/** |
| 27 | + - .github/workflows/wheels.yml |
| 28 | + workflow_dispatch: |
| 29 | + |
| 30 | +concurrency: |
| 31 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 32 | + cancel-in-progress: true |
| 33 | + |
| 34 | +permissions: |
| 35 | + contents: read |
| 36 | + |
| 37 | +jobs: |
| 38 | + deps: |
| 39 | + name: "${{ matrix.platform.name }}: dependencies" |
| 40 | + runs-on: ${{ matrix.platform.os }} |
| 41 | + timeout-minutes: 360 |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + platform: &platforms |
| 46 | + # deps_path: the Linux tarball directory (mounted at /host in the |
| 47 | + # manylinux container), the macOS/Windows install prefix. The |
| 48 | + # prefix must be the same in the deps and wheels jobs. |
| 49 | + - name: linux-x86_64 |
| 50 | + os: ubuntu-24.04 |
| 51 | + manylinux: quay.io/pypa/manylinux_2_28_x86_64 |
| 52 | + deps_path: /home/runner/pyocc-deps-cache |
| 53 | + deps_files: ci/wheels/deps/linux.sh |
| 54 | + - name: linux-aarch64 |
| 55 | + os: ubuntu-24.04-arm |
| 56 | + manylinux: quay.io/pypa/manylinux_2_28_aarch64 |
| 57 | + deps_path: /home/runner/pyocc-deps-cache |
| 58 | + deps_files: ci/wheels/deps/linux.sh |
| 59 | + - name: macos-x86_64 |
| 60 | + os: macos-15-intel |
| 61 | + arch: x86_64 |
| 62 | + deps_path: /Users/runner/pyocc-deps |
| 63 | + deps_files: ci/wheels/deps/macos.sh ci/wheels/triplets/x64-osx-pyocc.cmake |
| 64 | + - name: macos-arm64 |
| 65 | + os: macos-15 |
| 66 | + arch: arm64 |
| 67 | + deps_path: /Users/runner/pyocc-deps |
| 68 | + deps_files: ci/wheels/deps/macos.sh ci/wheels/triplets/arm64-osx-pyocc.cmake |
| 69 | + - name: windows-AMD64 |
| 70 | + os: windows-2022 |
| 71 | + arch: AMD64 |
| 72 | + deps_path: C:/pyocc-deps |
| 73 | + deps_files: ci/wheels/deps/windows.ps1 ci/wheels/triplets/x64-windows-pyocc.cmake |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v7 |
| 76 | + |
| 77 | + - id: key |
| 78 | + name: Dependencies cache key |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + set -eu |
| 82 | + # bump DEPS_CACHE_VERSION to invalidate the caches |
| 83 | + DEPS_CACHE_VERSION=1 |
| 84 | + HASH=$(cat ${{ matrix.platform.deps_files }} | sha256sum | cut -c1-16) |
| 85 | + echo "key=pyocc-deps-${{ matrix.platform.name }}-${DEPS_CACHE_VERSION}-${HASH}" >> "$GITHUB_OUTPUT" |
| 86 | +
|
| 87 | + - id: cache |
| 88 | + uses: actions/cache@v6 |
| 89 | + with: |
| 90 | + path: ${{ matrix.platform.deps_path }} |
| 91 | + key: ${{ steps.key.outputs.key }} |
| 92 | + |
| 93 | + - name: Build SWIG and OCCT (manylinux container) |
| 94 | + if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux' |
| 95 | + run: | |
| 96 | + set -eux |
| 97 | + mkdir -p "${{ matrix.platform.deps_path }}" |
| 98 | + docker run --rm \ |
| 99 | + -v "$GITHUB_WORKSPACE:/project" \ |
| 100 | + -v "${{ matrix.platform.deps_path }}:/deps-cache" \ |
| 101 | + -e PYOCC_DEPS_CACHE=/deps-cache \ |
| 102 | + ${{ matrix.platform.manylinux }} \ |
| 103 | + bash /project/ci/wheels/deps/linux.sh |
| 104 | +
|
| 105 | + - name: Build SWIG and OCCT |
| 106 | + if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS' |
| 107 | + run: bash ci/wheels/deps/macos.sh |
| 108 | + env: |
| 109 | + ARCH: ${{ matrix.platform.arch }} |
| 110 | + PYOCC_DEPS_PREFIX: ${{ matrix.platform.deps_path }} |
| 111 | + |
| 112 | + - name: Build OCCT |
| 113 | + if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Windows' |
| 114 | + run: ./ci/wheels/deps/windows.ps1 |
| 115 | + shell: pwsh |
| 116 | + env: |
| 117 | + PYOCC_DEPS_PREFIX: ${{ matrix.platform.deps_path }} |
| 118 | + |
| 119 | + wheels: |
| 120 | + name: "${{ matrix.platform.name }}: ${{ matrix.python }}" |
| 121 | + needs: deps |
| 122 | + runs-on: ${{ matrix.platform.os }} |
| 123 | + timeout-minutes: 360 |
| 124 | + strategy: |
| 125 | + fail-fast: false |
| 126 | + matrix: |
| 127 | + platform: *platforms |
| 128 | + python: [cp310, cp311, cp312, cp313, cp314] |
| 129 | + steps: |
| 130 | + - uses: actions/checkout@v7 |
| 131 | + |
| 132 | + - id: key |
| 133 | + name: Dependencies cache key |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + set -eu |
| 137 | + # must match the deps job |
| 138 | + DEPS_CACHE_VERSION=1 |
| 139 | + HASH=$(cat ${{ matrix.platform.deps_files }} | sha256sum | cut -c1-16) |
| 140 | + echo "key=pyocc-deps-${{ matrix.platform.name }}-${DEPS_CACHE_VERSION}-${HASH}" >> "$GITHUB_OUTPUT" |
| 141 | +
|
| 142 | + - uses: actions/cache/restore@v6 |
| 143 | + with: |
| 144 | + path: ${{ matrix.platform.deps_path }} |
| 145 | + key: ${{ steps.key.outputs.key }} |
| 146 | + fail-on-cache-miss: true |
| 147 | + |
| 148 | + - uses: pypa/cibuildwheel@v4.2.1 |
| 149 | + env: |
| 150 | + CIBW_BUILD: ${{ matrix.python }}-* |
| 151 | + CIBW_ARCHS_MACOS: ${{ matrix.platform.arch }} |
| 152 | + # Linux: the host filesystem is mounted at /host in the container |
| 153 | + PYOCC_DEPS_CACHE: /host${{ matrix.platform.deps_path }} |
| 154 | + PYOCC_DEPS_PREFIX: ${{ matrix.platform.deps_path }} |
| 155 | + |
| 156 | + - uses: actions/upload-artifact@v7 |
| 157 | + with: |
| 158 | + name: wheels-${{ matrix.platform.name }}-${{ matrix.python }} |
| 159 | + path: wheelhouse/*.whl |
| 160 | + |
| 161 | + sdist: |
| 162 | + name: Source distribution |
| 163 | + runs-on: ubuntu-24.04 |
| 164 | + steps: |
| 165 | + - uses: actions/checkout@v7 |
| 166 | + - run: pipx run build --sdist |
| 167 | + - uses: actions/upload-artifact@v7 |
| 168 | + with: |
| 169 | + name: sdist |
| 170 | + path: dist/*.tar.gz |
| 171 | + |
| 172 | + publish: |
| 173 | + name: Upload to PyPI |
| 174 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 175 | + needs: [wheels, sdist] |
| 176 | + runs-on: ubuntu-24.04 |
| 177 | + # the trusted publisher configured on PyPI for this repository, this |
| 178 | + # workflow and this environment |
| 179 | + environment: |
| 180 | + name: pypi |
| 181 | + url: https://pypi.org/p/pythonocc-core |
| 182 | + permissions: |
| 183 | + id-token: write |
| 184 | + steps: |
| 185 | + - uses: actions/download-artifact@v8 |
| 186 | + with: |
| 187 | + path: dist |
| 188 | + merge-multiple: true |
| 189 | + - run: ls -l dist |
| 190 | + - uses: pypa/gh-action-pypi-publish@v1.14.2 |
0 commit comments