-
Notifications
You must be signed in to change notification settings - Fork 11
354 lines (308 loc) · 10.9 KB
/
python-release.yml
File metadata and controls
354 lines (308 loc) · 10.9 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
name: Python Artifacts
env:
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
on:
push:
branches:
- dev
- development
- master
tags:
- 'py-*'
pull_request:
branches:
- dev
- development
- master
workflow_dispatch:
inputs:
sha:
description: Commit SHA
type: string
dry_run:
description: 'Dry run (build but not publish)'
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
check_pr_push:
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' && github.event.action != 'closed' ||
github.event_name == 'push' && contains(fromJSON('["master", "dev", "development"]'), github.ref_name)
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- name: Check if should run on PR push
id: check
run: |
# Always run on pushes to main branches
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref_name }}" =~ ^(master|dev|development)$ ]]; then
echo "run=true" >> $GITHUB_OUTPUT
# For PRs, check the TRIGGER_ON_PR_PUSH setting
elif [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ env.TRIGGER_ON_PR_PUSH }}" = "true" ]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "run=false" >> $GITHUB_OUTPUT
fi
build_wheels_pecos_rslib:
needs: check_pr_push
if: needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
architecture: [ x86_64, aarch64 ]
exclude:
- os: windows-latest
architecture: aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist --interpreter python3.10
working-directory: python/pecos-rslib
target: ${{ matrix.architecture == 'aarch64' && (matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu') || (matrix.os == 'macos-latest' && 'x86_64-apple-darwin' || '') }}
manylinux: auto
before-script-linux: |
if command -v yum &> /dev/null; then
yum install -y openssl-devel
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y libssl-dev pkg-config
else
echo "No supported package manager found"
exit 1
fi
- name: Restore README.md
if: always()
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi
- name: Test wheel is abi3
run: |
# Check that the wheel has abi3 tag
ls -la python/pecos-rslib/dist/
wheel_file=$(ls python/pecos-rslib/dist/*.whl)
echo "Built wheel: $wheel_file"
if [[ $wheel_file == *"abi3"* ]]; then
echo "Wheel has abi3 tag"
else
echo "ERROR: Wheel does not have abi3 tag!"
exit 1
fi
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-pecos-rslib-${{ matrix.os }}-${{ matrix.architecture }}
path: python/pecos-rslib/dist/*.whl
test_abi3_wheels:
needs: build_wheels_pecos_rslib
if: |
always() &&
needs.build_wheels_pecos_rslib.result == 'success'
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
platform:
- runner: ubuntu-latest
os: ubuntu-latest
architecture: x86_64
- runner: windows-latest
os: windows-latest
architecture: x86_64
- runner: macos-13
os: macos-latest
architecture: x86_64
- runner: macos-latest
os: macos-latest
architecture: aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download abi3 wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-${{ matrix.platform.os }}-${{ matrix.platform.architecture }}
path: ./pecos-rslib-wheel
- name: Test abi3 wheel with Python ${{ matrix.python-version }}
run: |
echo "Testing abi3 wheel with Python ${{ matrix.python-version }}"
python --version
pip install --force-reinstall --verbose ./pecos-rslib-wheel/*.whl
python -c 'import pecos_rslib; print(f"pecos_rslib version: {pecos_rslib.__version__}")'
python -c 'import sys; print(f"Python version: {sys.version}")'
build_sdist_quantum_pecos:
needs: build_wheels_pecos_rslib
if: |
always() &&
needs.build_wheels_pecos_rslib.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64
path: ./pecos-rslib-wheel
- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl
- name: Install pecos RNG build dependencies
run: |
pip install build nanobind
- name: Build PECOS RNG
run: |
cd clib/pecos-rng && mkdir build && cd build/ && cmake ..
make && cd .. && pip install .
env:
NANOBIND_DIR: python -m nanobind --include_dir
- name: Build quantum-pecos SDist
run: |
cd python/quantum-pecos
python -m build --sdist --outdir dist
- name: Test quantum-pecos SDist
run: |
pip install python/quantum-pecos/dist/*.tar.gz
python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos SDist
uses: actions/upload-artifact@v4
with:
name: sdist-quantum-pecos
path: python/quantum-pecos/dist/*.tar.gz
build_wheels_quantum_pecos:
needs: build_wheels_pecos_rslib
if: |
always() &&
needs.build_wheels_pecos_rslib.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64
path: ./pecos-rslib-wheel
- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl
- name: Install pecos rng build dependencies
run: |
pip install build nanobind
- name: Build PECOS RNG
run: |
cd clib/pecos-rng && mkdir build && cd build/ && cmake ..
make && cd .. && pip install .
env:
NANOBIND_DIR: python -m nanobind --include_dir
- name: Build quantum-pecos wheel
run: |
cd python/quantum-pecos
python -m build --wheel --outdir dist
- name: Test quantum-pecos wheel
run: |
pip install python/quantum-pecos/dist/*.whl
python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos wheel
uses: actions/upload-artifact@v4
with:
name: wheel-quantum-pecos
path: python/quantum-pecos/dist/*.whl
collect_artifacts:
needs: [build_wheels_pecos_rslib, build_sdist_quantum_pecos, build_wheels_quantum_pecos, test_abi3_wheels]
if: |
needs.build_wheels_pecos_rslib.result == 'success' &&
needs.build_sdist_quantum_pecos.result == 'success' &&
needs.build_wheels_quantum_pecos.result == 'success' &&
needs.test_abi3_wheels.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Create distribution directories
run: |
mkdir -p dist/pecos-rslib
mkdir -p dist/quantum-pecos
# Download artifacts into temp directory first
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: temp-artifacts/
- name: Organize distribution files
run: |
# Debug: Show what we downloaded
echo "=== Downloaded artifacts structure ==="
ls -la temp-artifacts/
# Move pecos-rslib wheels to distribution directory
for artifact in temp-artifacts/wheel-pecos-rslib-*/; do
if [ -d "$artifact" ]; then
echo "Processing $artifact"
mv "$artifact"*.whl dist/pecos-rslib/ 2>/dev/null || true
fi
done
# Move quantum-pecos files to distribution directory
for artifact in temp-artifacts/*-quantum-pecos*/; do
if [ -d "$artifact" ]; then
echo "Processing $artifact"
mv "$artifact"*.whl dist/quantum-pecos/ 2>/dev/null || true
mv "$artifact"*.tar.gz dist/quantum-pecos/ 2>/dev/null || true
fi
done
# Clean up
rm -rf temp-artifacts
- name: List all collected artifacts
run: |
echo "=== pecos-rslib artifacts ==="
ls -la dist/pecos-rslib/
echo ""
echo "=== quantum-pecos artifacts ==="
ls -la dist/quantum-pecos/
echo ""
echo "=== Summary ==="
echo "pecos-rslib wheels: $(ls -1 dist/pecos-rslib/*.whl 2>/dev/null | wc -l)"
echo "quantum-pecos distributions: $(ls -1 dist/quantum-pecos/* 2>/dev/null | wc -l)"
- name: Upload distribution bundle
uses: actions/upload-artifact@v4
with:
name: pecos-distribution
path: dist/