Remove macos-15-large, build only for macOS ARM (macos-latest) #18
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 | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] # Linux, macOS ARM | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.21 | |
| env: | |
| # Only build for Python 3.12+ | |
| CIBW_BUILD: "cp312-*" | |
| # Skip 32-bit builds and musl (Alpine) on Linux | |
| CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*" | |
| # Install system dependencies before building (Linux) | |
| CIBW_BEFORE_ALL_LINUX: | | |
| yum install -y openmpi-devel | |
| # Install system dependencies before building (macOS) | |
| CIBW_BEFORE_ALL_MACOS: | | |
| brew install open-mpi | |
| # Install Python build dependencies including NEURON | |
| CIBW_BEFORE_BUILD_LINUX: | | |
| pip install neuron==8.2.7 setuptools Cython numpy scipy | |
| CIBW_BEFORE_BUILD_MACOS: | | |
| pip install neuron setuptools Cython numpy scipy | |
| # Use manylinux2014 (manylinux_2_17) | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
| # Exclude MPI libraries from bundling (users must install system MPI) | |
| # This allows auditwheel to create valid manylinux wheels | |
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | |
| auditwheel repair -w {dest_dir} {wheel} | |
| --exclude libmpi.so.40 | |
| --exclude libmpi.so.12 | |
| --exclude libopen-pal.so.40 | |
| --exclude libopen-rte.so.40 | |
| --plat manylinux_2_17_x86_64 | |
| - name: Show built wheel names | |
| run: ls -lh wheelhouse/ | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| 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@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] # Match build_wheels matrix | |
| 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 }} | |
| 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 == '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@v4 | |
| with: | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Upload artifacts to GitHub Release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |