Skip to content

Docs: Sphinx → properdocs migration + descending-drive Poisson fix (+ Optuna parallelization) #214

Docs: Sphinx → properdocs migration + descending-drive Poisson fix (+ Optuna parallelization)

Docs: Sphinx → properdocs migration + descending-drive Poisson fix (+ Optuna parallelization) #214

Workflow file for this run

name: Build Wheels
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
release:
types: [published]
workflow_dispatch:
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-latest = arm64 (Apple Silicon). Intel (x86_64) macos-13
# runner dropped — GitHub is retiring it.
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v5
- name: Build wheels
uses: pypa/cibuildwheel@v2.21
env:
# Build for Python 3.12 and 3.13
CIBW_BUILD: "cp312-* cp313-*"
# Skip 32-bit builds and musl (Alpine) on Linux
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*"
# Install system dependencies before building (Linux).
# On manylinux_2_28 scipy installs from a prebuilt wheel, so the
# openblas-devel that the old source-build fallback needed (and which
# lives in the PowerTools repo on AlmaLinux 8) is no longer required.
CIBW_BEFORE_ALL_LINUX: |
yum install -y openmpi-devel
# Install system dependencies before building (macOS)
CIBW_BEFORE_ALL_MACOS: |
brew install open-mpi
# Ensure command line tools are available
xcode-select --install 2>/dev/null || true
# Install NEURON for nrnivmodl, set NMODL_PYLIB to skip find_libpython() which fails in manylinux
# Run nrnivmodl from within nmodl_files directory so compiled output stays there
CIBW_BEFORE_BUILD_LINUX: |
pip install neuron==8.2.7
cd myogen/simulator/nmodl_files && NMODL_PYLIB="" nrnivmodl .
CIBW_BEFORE_BUILD_MACOS: |
pip install neuron==8.2.7
cd myogen/simulator/nmodl_files && nrnivmodl .
# manylinux_2_28 (glibc >= 2.28) so scipy >= 1.17 prebuilt wheels are
# available in the build container (scipy dropped manylinux2014).
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
# Custom repair to preserve NEURON mechanisms while adding proper platform tags
# Standard tools (auditwheel/delocate) strip the architecture directories
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
python -c "
import shutil, sys
from pathlib import Path
wheel = Path(sys.argv[1])
dest = Path(sys.argv[2])
# Rename to manylinux without modifying contents
new_name = wheel.name.replace('linux_', 'manylinux_2_28_').replace('manylinux2014_', 'manylinux_2_28_')
shutil.copy2(wheel, dest / new_name)
" {wheel} {dest_dir}
# macOS: Just copy wheel as-is (already has correct platform tag)
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "cp {wheel} {dest_dir}/"
- name: Show built wheel names
run: ls -lh wheelhouse/
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
retention-days: 7
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build sdist
run: python -m build --sdist --outdir dist/
- name: Upload sdist
uses: actions/upload-artifact@v6
with:
name: sdist
path: dist/*.tar.gz
retention-days: 7
test_wheels:
name: Test wheel on ${{ matrix.os }}
needs: [build_wheels]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # Match build_wheels matrix
python-version: ["3.12", "3.13"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Download wheels
uses: actions/download-artifact@v7
with:
name: wheels-${{ matrix.os }}
path: dist/
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y openmpi-bin libopenmpi-dev
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install open-mpi
- name: Install NEURON
run: |
python -m pip install --upgrade pip
pip install neuron==8.2.7
- name: Install wheel
run: |
# dist/ now holds both cp312 and cp313 wheels; install only the one
# matching this runner's Python so pip doesn't reject the other ABI.
tag="cp$(echo '${{ matrix.python-version }}' | tr -d .)"
pip install dist/*"${tag}-${tag}"*.whl
- name: Test import
run: |
python -c "import myogen; print('MyoGen imported successfully')"
python -c "from myogen.simulator import Muscle, SurfaceEMG; print('Core components OK')"
- name: Test NEURON components (Linux only)
if: runner.os == 'Linux'
run: |
python -c "from myogen.simulator.neuron.populations import AlphaMN__Pool; print('NEURON components OK')"
publish:
name: Publish to PyPI
needs: [build_wheels, build_sdist, test_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
permissions:
id-token: write # Required for OIDC publishing
contents: write # Required for uploading release assets
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: dist/
merge-multiple: true
- name: Upload artifacts to GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v3
with:
files: dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true