Repository navigation
180 lines (161 loc) · 5.2 KB
/
Copy pathbuild-necpp-wheels.yml
File metadata and controls
180 lines (161 loc) · 5.2 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
# Copyright (c) 2008-2026 Tim Molteno (tim@elec.ac.nz)
name: Build and upload necpp to PyPI
on:
workflow_dispatch:
release:
types:
- published
env:
# SWIG >= 4.4.1 is required for Py_LIMITED_API builds (heap types landed in
# 4.4.0, Py_LIMITED_API fixes in 4.4.1); 4.5.1 is the current release and is
# pinned so all four platforms generate identical wrappers.
SWIG_VERSION: "4.5.1"
jobs:
build_wheels:
name: Build necpp wheels on ${{ matrix.os }}
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [linux, macos-arm, macos-x64, windows]
include:
- os: linux
runs-on: ubuntu-latest
- os: macos-arm
runs-on: macos-latest
# Intel macOS: macos-13 and the macOS 14 x64 images are retired
# (2026-11-02); macos-15-intel is the current x64 label.
- os: macos-x64
runs-on: macos-15-intel
- os: windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python (SWIG tooling)
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pinned SWIG
shell: bash
run: python -m pip install "swig==$SWIG_VERSION"
# No CMake configure/build needed: setup.py writes necpp_src/build/
# config.h itself (same two macros as src/config.h.in).
- name: Setup package directory and generate SWIG wrapper
shell: bash
run: |
cd necpp
if [ "$RUNNER_OS" = "Windows" ]; then
# Git Bash symlink support for directories is unreliable; copy.
cp -r ../necpp_src .
else
ln -s ../necpp_src .
fi
swig -I../necpp_src/src/ -python necpp.i
- name: Build wheels
uses: pypa/cibuildwheel@v4.1.0
env:
# One cp311-abi3 wheel per platform (works on CPython 3.11+),
# instead of one wheel per Python version.
CIBW_BUILD: "cp311-*"
CIBW_SKIP: "*-musllinux_*"
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: necpp
output-dir: wheelhouse
- name: Audit wheels against the stable ABI
shell: bash
run: |
python -m pip install abi3audit
abi3audit -sS wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-necpp-${{ matrix.os }}
path: ./wheelhouse/*.whl
test:
name: Test necpp on ${{ matrix.os }} / py${{ matrix.python }}
needs: [build_wheels, build_sdist]
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python: ["3.11", "3.14"]
os: [linux, macos-arm, macos-x64, windows]
include:
- os: linux
runs-on: ubuntu-latest
- os: macos-arm
runs-on: macos-latest
- os: macos-x64
runs-on: macos-15-intel
- os: windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-necpp-${{ matrix.os }}
path: wheelhouse
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install the abi3 wheel and run tests
# Exactly one cp311-abi3 wheel per platform: it must install and pass
# on every supported CPython (3.11 through 3.14) — this proves it.
shell: bash
run: |
pip install "$(ls wheelhouse/*-abi3-*.whl | head -1)"
pip install pytest
python -m pytest necpp/tests/ -v
build_sdist:
name: Build necpp source distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python (SWIG tooling)
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pinned SWIG
run: python -m pip install "swig==$SWIG_VERSION"
- name: Setup package directory and generate SWIG wrapper
run: |
cd necpp
ln -s ../necpp_src .
swig -I../necpp_src/src/ -python necpp.i
# The sdist ships the pre-generated wrapper, so end users never need SWIG.
- name: Build sdist
run: |
cd necpp
pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist-necpp
path: necpp/dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1