Repository navigation
114 lines (104 loc) · 3.7 KB
/
Copy pathpython-publish.yml
File metadata and controls
114 lines (104 loc) · 3.7 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
name: Build wheels and publish
# Builds portable binary wheels (with the compiled Cython kernel) for every
# supported platform/Python via cibuildwheel, plus an sdist, and publishes them
# to PyPI on a version tag. Source installs without a compiler still work via the
# pure-Python fallback.
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-14 (Apple Silicon) cross-builds both macOS arches, so the
# scarce/slow-to-schedule Intel macos-13 runner is no longer needed.
os: [ubuntu-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Generate VERSION.txt
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "${GITHUB_REF##*/}" | sed 's/^v//' > VERSION.txt
else
echo "0.0.0.dev0" > VERSION.txt
fi
- name: Build wheels
uses: pypa/cibuildwheel@v2.21
env:
# CPython 3.9-3.13, 64-bit; skip the slow/rare targets
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
CIBW_SKIP: "*-musllinux_* *_i686 *_ppc64le *_s390x pp*"
# Build Intel + Apple Silicon macOS wheels from the single arm64 runner.
# No wheel tests run here, so cross-compiled x86_64 wheels are fine.
CIBW_ARCHS_MACOS: "x86_64 arm64"
# Verify each wheel shipped the compiled kernel by inspecting its contents
# instead of importing mlquantify. Importing would reinstall the full
# runtime stack, and the latest scipy/scikit-learn no longer ship
# manylinux2014 wheels, so that install tries to build scipy from source
# and fails (no OpenBLAS in the build container).
- name: Verify compiled kernel is in each wheel
shell: bash
run: |
python - <<'PY'
import glob, sys, zipfile
wheels = glob.glob("wheelhouse/*.whl")
assert wheels, "no wheels were built"
missing = [
w for w in wheels
if not any(
"_histogram_sweep" in n and n.endswith((".so", ".pyd"))
for n in zipfile.ZipFile(w).namelist()
)
]
if missing:
print("compiled histogram-sweep kernel missing from:")
print(*(" " + w for w in missing), sep="\n")
sys.exit(1)
print(f"OK: compiled kernel present in all {len(wheels)} wheel(s)")
PY
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
build_sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate VERSION.txt
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "${GITHUB_REF##*/}" | sed 's/^v//' > VERSION.txt
else
echo "0.0.0.dev0" > VERSION.txt
fi
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
publish:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist