-
Notifications
You must be signed in to change notification settings - Fork 4
233 lines (208 loc) · 8.58 KB
/
ci.yml
File metadata and controls
233 lines (208 loc) · 8.58 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
name: CI
on:
push:
branches: [master]
tags: ["v*"]
pull_request:
branches: [master]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install linters
run: pip install ruff cython-lint
- name: Lint Python with ruff
run: ruff check . --ignore SIM103
- name: Lint advisories (non-blocking)
run: ruff check . --select SIM103 || true
- name: Lint Cython
run: >
cython-lint
wlsqm/fitter/defs.pyx wlsqm/fitter/defs.pxd
wlsqm/fitter/infra.pyx wlsqm/fitter/infra.pxd
wlsqm/fitter/impl.pyx wlsqm/fitter/impl.pxd
wlsqm/fitter/polyeval.pyx wlsqm/fitter/polyeval.pxd
wlsqm/fitter/interp.pyx wlsqm/fitter/interp.pxd
wlsqm/fitter/simple.pyx wlsqm/fitter/simple.pxd
wlsqm/fitter/expert.pyx
wlsqm/utils/lapackdrivers.pyx wlsqm/utils/lapackdrivers.pxd
wlsqm/utils/ptrwrap.pyx wlsqm/utils/ptrwrap.pxd
|| true
test:
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
# Apple Clang does not ship an OpenMP runtime; install libomp so that
# meson's `dependency('openmp', required: false)` can find it. If meson
# still cannot discover it the build falls back to serial and the tests
# still pass, but installing libomp keeps the macOS runner on the same
# parallel code path as Linux/Windows whenever possible.
- name: Install libomp (macOS)
if: runner.os == 'macOS'
run: brew install libomp
- name: Install build and test dependencies
run: pip install meson-python meson ninja Cython numpy scipy pytest
- name: Install wlsqm
run: pip install --no-build-isolation -e .
# Diagnose Windows DLL-load failures: first run said vcomp140 is
# resolvable via ctypes, so the problem is deeper in the chain. Use
# pefile to dump the DLL-level import table of every built .pyd, then
# probe each .pyd with ctypes.WinDLL (which only exercises the Windows
# loader — PyInit never runs, so a WinDLL failure means Windows could
# not resolve a direct DLL import, whereas a WinDLL success + Python
# import failure means the Cython cimport chain in PyInit is what
# fails).
- name: Diagnose extension DLL dependencies (Windows)
if: runner.os == 'Windows'
# Use Git Bash so the Python heredoc works. PowerShell does not
# understand `python - <<'PY' ... PY` and chokes at parse time.
shell: bash
run: |
python -m pip install -q pefile
python - <<'PY'
import ctypes, glob, importlib.util, os, sys, traceback
import pefile
print('python:', sys.version)
print('prefix:', sys.prefix)
# meson-python editable install drops the compiled .pyd files
# under build/<tag>/wlsqm/..., not under the source tree. The
# editable loader redirects imports there, so that is where we
# have to look.
pyds = sorted(glob.glob('build/**/*.pyd', recursive=True))
print('=== built .pyd files ===')
for p in pyds:
print(' ', p)
print()
print('=== DLL-level imports per .pyd (pefile) ===')
for p in pyds:
try:
pe = pefile.PE(p, fast_load=True)
pe.parse_data_directories(directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_IMPORT']])
imports = [e.dll.decode(errors='replace') for e in getattr(pe, 'DIRECTORY_ENTRY_IMPORT', [])]
print(f' {p} ->')
for name in imports:
print(f' {name}')
pe.close()
except Exception as e:
print(f' {p} -> pefile error: {e}')
print()
print('=== ctypes.WinDLL probe per .pyd (DLL-level LoadLibrary only, no PyInit) ===')
for p in pyds:
try:
ctypes.WinDLL(os.path.abspath(p))
print(f' WinDLL OK : {p}')
except OSError as e:
print(f' WinDLL FAIL: {p} -- {e}')
print()
print('=== importlib spec-load probe (runs PyInit for each .pyd individually) ===')
# spec_from_file_location loads a .pyd by filesystem path and
# runs its PyInit without going through wlsqm/__init__.py. This
# isolates which module's PyInit is the first to raise.
#
# Extensions that `cimport` other wlsqm modules will still
# trigger Python-level imports during PyInit, and those
# DO go through the package machinery — but we load in
# dependency order below, so by the time simple.pyx's PyInit
# runs, its cimported deps are already in sys.modules.
load_order = [
('wlsqm.fitter.defs', 'fitter/defs'),
('wlsqm.fitter.infra', 'fitter/infra'),
('wlsqm.fitter.polyeval', 'fitter/polyeval'),
('wlsqm.utils.ptrwrap', 'utils/ptrwrap'),
('wlsqm.utils.lapackdrivers', 'utils/lapackdrivers'),
('wlsqm.fitter.interp', 'fitter/interp'),
('wlsqm.fitter.impl', 'fitter/impl'),
('wlsqm.fitter.simple', 'fitter/simple'),
('wlsqm.fitter.expert', 'fitter/expert'),
]
def find_pyd(subpath):
# subpath is like 'fitter/defs' or 'utils/lapackdrivers'.
# Match by subdir + filename stem; the ABI tag varies with
# the Python version in the test matrix, so we don't hardcode it.
subdir, stem = subpath.split('/')
for p in pyds:
norm = p.replace('\\', '/')
if f'/{subdir}/' in norm and os.path.basename(norm).split('.')[0] == stem:
return p
return None
for fqname, subpath in load_order:
p = find_pyd(subpath)
if p is None:
print(f' not found : {fqname}')
continue
try:
spec = importlib.util.spec_from_file_location(fqname, p)
mod = importlib.util.module_from_spec(spec)
sys.modules[fqname] = mod
spec.loader.exec_module(mod)
print(f' PyInit OK : {fqname} ({p})')
except Exception as e:
print(f' PyInit FAIL: {fqname} ({p})')
print(f' {type(e).__name__}: {e}')
traceback.print_exc()
break
PY
continue-on-error: true
- name: Run tests
run: pytest tests/ -v
build-wheels:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
# cibuildwheel config lives in pyproject.toml ([tool.cibuildwheel]) —
# build list, skip list, test-requires, test-command, and the macOS
# before-all that installs libomp.
- uses: pypa/cibuildwheel@v3.4
- uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
sdist:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: pip install build
- run: python -m build --sdist
- uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build-wheels, sdist]
runs-on: ubuntu-latest
# Requires the `pypi` environment to be configured on GitHub with a
# trusted publisher for this repo + workflow + environment. No API token
# stored as a secret; the job mints a short-lived OIDC token instead.
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
path: dist/
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/