Skip to content

Commit fd41eae

Browse files
committed
⚡ Cache wheel builds with sccache
Configure the supported sccache action and CMake compiler launchers for wheel builds. Match the existing main-only cache write policy, retain statistics for long jobs, and document the Linux container environment handoff. Assisted-by: GPT-6 via Codex
1 parent fd3d75d commit fd41eae

3 files changed

Lines changed: 44 additions & 10 deletions

File tree

‎.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ jobs:
5858
name: 🎡 ${{ inputs.runs-on }}
5959
runs-on: ${{ inputs.runs-on }}
6060
env:
61+
CMAKE_C_COMPILER_LAUNCHER: sccache
62+
CMAKE_CXX_COMPILER_LAUNCHER: sccache
63+
SCCACHE_GHA_ENABLED: true
64+
SCCACHE_IDLE_TIMEOUT: 0
65+
SCCACHE_GHA_RW_MODE: ${{ github.ref == 'refs/heads/main' && 'READ_WRITE' || 'READ_ONLY' }}
6166
IQM_TOKEN: ${{ secrets.IQM_TOKEN }}
6267
IQM_QC_ALIAS: ${{ secrets.IQM_QC_ALIAS }}
6368
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
@@ -89,13 +94,11 @@ jobs:
8994
enable-cache: ${{ !startsWith(inputs.runs-on, 'ubuntu') }}
9095
save-cache: ${{ github.ref == 'refs/heads/main' }}
9196

92-
# set up sccache for faster builds (non-Ubuntu only)
93-
- name: Install sccache
94-
if: ${{ !startsWith(inputs.runs-on, 'ubuntu') }}
95-
run: uv tool install sccache
97+
- name: Set up sccache
98+
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
9699

97-
# run cibuildwheel to build wheels for the specified Python version
98-
- uses: pypa/cibuildwheel@adba99c781d3746d38b3a09b1cf797965bcb7fe6 # v4.3.0
100+
- name: Build wheels
101+
uses: pypa/cibuildwheel@adba99c781d3746d38b3a09b1cf797965bcb7fe6 # v4.3.0
99102

100103
- name: Verify clean directory
101104
run: git diff --exit-code
@@ -107,7 +110,3 @@ jobs:
107110
with:
108111
name: ${{ github.event_name == 'pull_request' && 'dev-' || '' }}cibw-wheels-${{ inputs.runs-on }}
109112
path: wheelhouse/*.whl
110-
111-
- name: Show sccache stats
112-
if: ${{ !startsWith(inputs.runs-on, 'ubuntu') }}
113-
run: sccache --show-stats

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ releases may include breaking changes.
1010

1111
## [Unreleased]
1212

13+
### Changed
14+
15+
- ⚡ Enable shared `sccache` for native wheel builds through the supported
16+
action. Only `main` writes to the cache; other refs read from it. Linux
17+
consumers forward the cache environment into cibuildwheel containers ([#464])
18+
([**@burgholzer**])
19+
1320
## [2.5.1] - 2026-10-07
1421

1522
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#251)._
@@ -623,6 +630,7 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._
623630
[#474]: https://github.com/munich-quantum-toolkit/workflows/pull/474
624631
[#472]: https://github.com/munich-quantum-toolkit/workflows/pull/472
625632
[#470]: https://github.com/munich-quantum-toolkit/workflows/pull/470
633+
[#464]: https://github.com/munich-quantum-toolkit/workflows/pull/464
626634
[#463]: https://github.com/munich-quantum-toolkit/workflows/pull/463
627635
[#462]: https://github.com/munich-quantum-toolkit/workflows/pull/462
628636
[#461]: https://github.com/munich-quantum-toolkit/workflows/pull/461

‎UPGRADING.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ of changes, including minor and patch releases, please refer to the
66

77
## [Unreleased]
88

9+
### Wheel compiler caching
10+
11+
The cibuildwheel workflow now configures CMake compiler launchers and the GitHub
12+
Actions `sccache` backend. Only `main` writes to the cache; other refs read from
13+
it. Project CMake settings must preserve the supplied launcher environment
14+
variables and use a generator that supports compiler launchers, such as Ninja.
15+
16+
Linux builds must install `sccache` inside their cibuildwheel containers and
17+
append these variables to `[tool.cibuildwheel.linux].environment-pass`:
18+
19+
```toml
20+
environment-pass = [
21+
"CMAKE_C_COMPILER_LAUNCHER",
22+
"CMAKE_CXX_COMPILER_LAUNCHER",
23+
"SCCACHE_GHA_ENABLED",
24+
"SCCACHE_GHA_RW_MODE",
25+
"SCCACHE_IDLE_TIMEOUT",
26+
"ACTIONS_CACHE_SERVICE_V2",
27+
"ACTIONS_RESULTS_URL",
28+
"ACTIONS_RUNTIME_TOKEN",
29+
]
30+
```
31+
32+
The action reports host-side statistics automatically. Linux projects can
33+
inspect container-side statistics in their cibuildwheel build hooks with
34+
`sccache --show-stats`.
35+
936
## [2.5.1]
1037

1138
MLIR-enabled workflows default to LLVM 23.1.2; set `llvm-version` explicitly to

0 commit comments

Comments
 (0)