Merge pull request #265 from qpv-research-group/pdd_sesame #111
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-latest, macosx, x86_64 ] | |
- [ macos-11, macosx, arm64] # cross compiled | |
- [ windows-2019, win, AMD64 ] | |
python: [[ "cp37", "3.7" ], [ "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@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- 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.16.2 | |
- name: Build Solcore | |
if: >- | |
( ! contains(matrix.buildplat[2], 'arm64' ) ) | |
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: Set extra env for arm64 | |
if: >- | |
( contains(matrix.buildplat[2], 'arm64' ) ) | |
run: | | |
echo "LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV; | |
echo "LIBRARY_PATH=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV; | |
- name: Cross-build Solcore for arm64 | |
if: ${{ (matrix.python[0] != 'cp37') && ( contains(matrix.buildplat[2], 'arm64') )}} # image not present for python3.7 | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}* | |
CIBW_ARCHS: ${{ matrix.buildplat[2] }} | |
CIBW_ENVIRONMENT: CFLAGS='-target arm64-apple-macos' | |
CIBW_BEFORE_BUILD_MACOS: bash {project}/build_tools/cibw_before_build_macos_arm.sh && meson setup --cross-file={project}/build_tools/x86_64-w64-arm64.ini build | |
CIBW_CONFIG_SETTINGS_MACOS: builddir=build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v3 | |
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@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Download wheel artifacts | |
uses: actions/download-artifact@v3 | |
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 |