Fix failing workflows: remove deprecated macos-12 runners, pkg-config… #135
This file contains 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: Upload Python Package | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
tags: | |
- "**" | |
jobs: | |
build_wheels: | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
# Ensure that a wheel builder finishes even if another fails | |
fail-fast: false | |
matrix: | |
# Github Actions doesn't support pairing matrix values together, let's improvise | |
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 | |
buildplat: | |
# should also be able to do multi-archs on a single entry, e.g. | |
# [windows-2019, win*, "AMD64 x86"]. However, those two require a different compiler setup | |
# so easier to separate out here. | |
- [ ubuntu-latest, manylinux, x86_64] | |
- [ ubuntu-latest, manylinux, i686] | |
- [ macos-13, macosx, x86_64 ] # Intel chip | |
- [ macos-latest, macosx, arm64] # ARM M1/M2 chip | |
- [ windows-latest, win, AMD64] | |
python: [[ "cp38", "3.8" ], [ "cp39", "3.9" ], | |
[ "cp310", "3.10" ], [ "cp311", "3.11" ], ["cp312", "3.12"]] | |
name: Build wheel for ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: install-rtools needed for windows | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
choco install rtools --version=4.0.0.20220206 --no-progress --force | |
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel==2.17.0 | |
- name: Build Solcore | |
if: ${{ matrix.buildplat[0] != 'macos-latest' }} | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}* | |
CIBW_ARCHS: ${{ matrix.buildplat[2] }} | |
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS | |
CIBW_BEFORE_BUILD_MACOS: brew reinstall gfortran | |
CIBW_BEFORE_BUILD_LINUX: python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true" | |
- name: Build Solcore (Apple Silicon M1/M2) | |
if: ${{ matrix.buildplat[0] == 'macos-latest' && matrix.python[0] != 'cp38' && matrix.python[0] != 'cp39' }} | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}* | |
CIBW_ARCHS: ${{ matrix.buildplat[2] }} | |
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS | |
CIBW_BEFORE_BUILD_MACOS: brew reinstall gfortran | |
CIBW_BEFORE_BUILD_LINUX: python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
upload_wheels: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download sdist artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifact | |
path: dist | |
- name: Download wheel artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: wheelhouse | |
- name: Move wheels to dist directory | |
run: | | |
cp wheelhouse/**/*.whl dist | |
ls dist/ | |
- name: Publish package | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} | |
packages_dir: dist/ | |
skip_existing: true |