Build Wheels #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Wheels | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| # Only Linux has full NEURON support via pip | |
| # Windows requires manual NEURON installer | |
| os: [ubuntu-latest, macos-latest] | |
| python-version: ["3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| openmpi-bin openmpi-common libopenmpi-dev \ | |
| librdmacm-dev libpsm2-dev \ | |
| infiniband-diags ibverbs-utils libibverbs-dev \ | |
| libfabric1 libfabric-dev \ | |
| build-essential | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install open-mpi | |
| - name: Install NEURON (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install neuron==8.2.7 | |
| - name: Install NEURON (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install neuron | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install build wheel setuptools Cython numpy scipy | |
| - name: Build wheel | |
| run: | | |
| python -m build --wheel --outdir dist/ | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} | |
| path: dist/*.whl | |
| retention-days: 7 | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| 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@v4 | |
| 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] | |
| python-version: ["3.12"] | |
| steps: | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} | |
| 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${{ runner.os == 'Linux' && '==8.2.7' || '' }} | |
| - name: Install wheel | |
| run: | | |
| pip install dist/*.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 == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| id-token: write # Required for OIDC publishing | |
| contents: read | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |