Skip to content

CI: beef up Windows DLL diagnostic with pefile + per-.pyd probes #3

CI: beef up Windows DLL diagnostic with pefile + per-.pyd probes

CI: beef up Windows DLL diagnostic with pefile + per-.pyd probes #3

Workflow file for this run

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'
shell: pwsh
run: |
python -m pip install -q pefile
python - <<'PY'
import ctypes, glob, os, sys, traceback
import pefile
print('python:', sys.version)
print('prefix:', sys.prefix)
pyds = sorted(glob.glob('wlsqm/**/*.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 load 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('=== Python-level import probe in dependency order ===')
mods = [
'wlsqm.fitter.defs',
'wlsqm.fitter.infra',
'wlsqm.fitter.polyeval',
'wlsqm.utils.ptrwrap',
'wlsqm.utils.lapackdrivers',
'wlsqm.fitter.interp',
'wlsqm.fitter.impl',
'wlsqm.fitter.simple',
'wlsqm.fitter.expert',
]
for name in mods:
try:
__import__(name)
print(f' import OK : {name}')
except Exception as e:
print(f' import FAIL: {name} -- {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/