-
Notifications
You must be signed in to change notification settings - Fork 16
222 lines (194 loc) · 8.16 KB
/
Copy pathpython_wheels.yml
File metadata and controls
222 lines (194 loc) · 8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Wheel builder for Python bindings
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- v*
permissions:
contents: read
jobs:
build-wheels:
name: Build KaMinPar Python wheel for ${{ matrix.python }}-${{ matrix.platform[1] }}
strategy:
matrix:
# On PRs, only build cp313 per platform to catch binding issues quickly.
# On pushes/tags, build the full matrix for releases.
python: ${{ github.event_name == 'pull_request' && fromJSON('["cp313"]') || fromJSON('["cp39", "cp310", "cp311", "cp312", "cp313", "cp313t", "pp39", "pp310", "pp311"]') }}
platform:
- [ubuntu-24.04, manylinux_x86_64]
- [ubuntu-24.04-arm, manylinux_aarch64]
- [macos-15, macosx_arm64]
fail-fast: false
runs-on: ${{ matrix.platform[0] }}
steps:
- name: Checkout KaMinPar
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Modify CMakeLists.txt for PR builds
if: github.event_name == 'pull_request'
run: |
REPO_NAME="${{ github.event.pull_request.head.repo.full_name }}"
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
if [[ ! "$REPO_NAME" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
echo "Invalid repository name: $REPO_NAME" >&2
exit 1
fi
if [[ ! "$BRANCH_NAME" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
echo "Invalid branch name: $BRANCH_NAME" >&2
exit 1
fi
sed -i.bak "s|GIT_REPOSITORY .*|GIT_REPOSITORY https://github.com/${REPO_NAME}.git|" bindings/python/CMakeLists.txt
sed -i.bak "s|GIT_TAG .*|GIT_TAG ${BRANCH_NAME}|" bindings/python/CMakeLists.txt
- name: Cache cibuildwheel virtualenv
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: cibw-cache
with:
path: ${{ runner.temp }}/cibw-cache
key: cibw-virtualenv-${{ runner.os }}-${{ runner.arch }}
- name: Pre-download virtualenv for cibuildwheel
if: steps.cibw-cache.outputs.cache-hit != 'true'
run: |
# cibuildwheel 2.23.0 pins virtualenv 20.29.2; update when bumping cibuildwheel
VENV_VERSION="20.29.2"
CACHE_DIR="${{ runner.temp }}/cibw-cache"
mkdir -p "$CACHE_DIR"
curl -sSL --retry 5 --retry-delay 10 --retry-all-errors \
-o "$CACHE_DIR/virtualenv-${VENV_VERSION}.pyz" \
"https://github.com/pypa/get-virtualenv/blob/${VENV_VERSION}/public/virtualenv.pyz?raw=true"
- name: Build wheels
uses: pypa/cibuildwheel@6cccd09a31908ffd175b012fb8bf4e1dbda3bc6c # v2.23.0
env:
CIBW_CACHE_PATH: ${{ runner.temp }}/cibw-cache
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.platform[1] }}
CIBW_ENVIRONMENT: SKBUILD_CMAKE_DEFINE="KAMINPAR_PYTHON_INSTALL_TBB=On"
CIBW_FREE_THREADED_SUPPORT: True
with:
package-dir: bindings/python
output-dir: bindings/python/dist
- name: Store wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: kaminpar-python-wheel-${{ matrix.python }}-${{ matrix.platform[1] }}
path: bindings/python/dist/
if-no-files-found: error
build-sdist:
name: Build KaMinPar Python source distribution
runs-on: ubuntu-24.04
steps:
- name: Checkout KaMinPar
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Modify CMakeLists.txt for PR builds
if: github.event_name == 'pull_request'
run: |
REPO_NAME="${{ github.event.pull_request.head.repo.full_name }}"
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
if [[ ! "$REPO_NAME" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
echo "Invalid repository name: $REPO_NAME" >&2
exit 1
fi
if [[ ! "$BRANCH_NAME" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
echo "Invalid branch name: $BRANCH_NAME" >&2
exit 1
fi
sed -i.bak "s|GIT_REPOSITORY .*|GIT_REPOSITORY https://github.com/${REPO_NAME}.git|" bindings/python/CMakeLists.txt
sed -i.bak "s|GIT_TAG .*|GIT_TAG ${BRANCH_NAME}|" bindings/python/CMakeLists.txt
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.13"
- name: Build source distribution
run: |
# Create a requirements file with pinned versions and hashes for security
echo "build==1.2.2.post1 --hash=sha256:1d61c0887fa860c01971625baae8bdd338e517b836a2f70dd1f7aa3a6b2fc5b5" > build-requirements.txt
echo "packaging==24.2 --hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759" >> build-requirements.txt
echo "pyproject_hooks==1.2.0 --hash=sha256:9e5c6bfa8dcc30091c74b0cf803c81fdd29d94f01992a7707bc97babb1141913" >> build-requirements.txt
# Install the required build dependencies using the requirements file and build the sdist
python -m pip install --require-hashes -r build-requirements.txt
python -m build --sdist bindings/python/
- name: Store sdist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: kaminpar-python-sdist
path: bindings/python/dist/
if-no-files-found: error
publish-to-testpypi:
name: Publish KaMinPar Python distribution to TestPyPI
if: github.repository_owner == 'KaHIP' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- build-wheels
- build-sdist
environment:
name: testpypi
url: https://test.pypi.org/p/kaminpar
permissions:
id-token: write
runs-on: ubuntu-24.04
steps:
- name: Download all the dists
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
pattern: kaminpar-python-*
merge-multiple: true
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true
verbose: true
publish-to-pypi:
name: Publish KaMinPar Python distribution to PyPI
if: github.repository_owner == 'KaHIP' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- build-wheels
- build-sdist
environment:
name: pypi
url: https://pypi.org/p/kaminpar
permissions:
id-token: write
runs-on: ubuntu-24.04
steps:
- name: Download all the dists
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
pattern: kaminpar-python-*
merge-multiple: true
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
skip-existing: true
print-hash: true
verbose: true
github-release:
name: Sign the KaMinPar Python distribution with Sigstore and upload them to GitHub Release
if: github.repository_owner == 'KaHIP' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
- publish-to-pypi
permissions:
contents: write
id-token: write
runs-on: ubuntu-24.04
steps:
- name: Download all the dists
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
pattern: kaminpar-python-*
merge-multiple: true
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46 # v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload Packages
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
files: dist/**
append_body: true
fail_on_unmatched_files: true