QuantLib-Risks wheels #3
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
# builds only on the following conditions: | |
# - pull requests into main | |
# - OR pushes of tags starting with v* | |
# - OR manual dispatch on repo | |
# publishes to test pypi if: | |
# - in auto-differentiation/QuantLib-Risks repository | |
# - AND pushes of tags starting with v* | |
# - OR manual dispatch on repo | |
# publishes to real PyPI if: | |
# - publish to Test PyPI worked (with all build conditions above) | |
# - and if it's a version tag (starting with v*) | |
name: QuantLib-Risks wheels | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
tags: | |
- v* | |
workflow_dispatch: | |
jobs: | |
build_wheels: | |
name: Wheels | |
strategy: | |
fail-fast: false | |
matrix: | |
buildplat: ["win_amd64", "macosx_x86_64", "manylinux_x86_64", "musllinux_x86_64"] | |
python: ["cp38", "cp39", "cp310", "cp311", "cp312"] | |
include: | |
- buildplat: "manylinux_x86_64" | |
os: ubuntu-20.04 | |
platform: linux | |
ccache: ccache | |
preset: linux-xad-gcc-ninja-release | |
- buildplat: "musllinux_x86_64" | |
os: ubuntu-20.04 | |
platform: linux | |
ccache: ccache | |
preset: linux-xad-gcc-ninja-release | |
- buildplat: "macosx_x86_64" | |
os: "macos-12" | |
platform: macos | |
ccache: ccache | |
preset: linux-xad-gcc-ninja-release | |
- buildplat: "win_amd64" | |
os: windows-2022 | |
platform: windows | |
ccache: sccache | |
preset: windows-xad-msvc-release | |
exclude: | |
# gives "is not a supported wheel on this platform" for some reason | |
- buildplat: "macosx_x86_64" | |
python: "cp38" | |
runs-on: ${{ matrix.os }} | |
env: | |
QL_PRESET: ${{ matrix.preset }} | |
CCACHE_EXE: ${{ matrix.ccache }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Setup Boost (Windows) | |
if: ${{ matrix.platform == 'windows' }} | |
run: | | |
choco install -y ninja | |
$Url = "https://downloads.sourceforge.net/project/boost/boost-binaries/1.84.0/boost_1_84_0-msvc-14.3-64.exe" | |
(New-Object System.Net.WebClient).DownloadFile($Url, "$RUNNER_TEMP\boost.exe") | |
Start-Process -Wait -FilePath "$RUNNER_TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost" | |
- name: Setup Boost (Mac) | |
if: ${{ matrix.platform == 'macos' }} | |
run: | | |
brew install boost | |
brew install ninja | |
brew install ccache | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
with: | |
key: ${{ matrix.buildplat }}-${{ matrix.python }} | |
variant: ${{ matrix.ccache }} | |
max-size: 650M | |
- name: Setup boost path (Win) | |
if: ${{ matrix.platform == 'windows' }} | |
shell: cmd | |
run: echo BOOST_ROOT=C:\local\boost >> %GITHUB_ENV% | |
- name: Store CCache dir (Linux) | |
if: ${{ matrix.platform == 'linux' }} | |
run: | | |
HOST_CCACHE_DIR="$(ccache -k cache_dir)" | |
mkdir -p $HOST_CCACHE_DIR | |
echo "HOST_CCACHE_DIR=${HOST_CCACHE_DIR}" >> $GITHUB_ENV | |
- name: Stub `setup.py` check (Linux/Mac) | |
if: ${{ matrix.platform != 'windows' }} | |
run: | | |
mkdir -p build/${{ matrix.preset }}/Python | |
touch build/${{ matrix.preset }}/Python/setup.py | |
- name: Stub `setup.py` check (Windows) | |
if: ${{ matrix.platform == 'windows' }} | |
shell: bash | |
run: | | |
mkdir -p build/${{ matrix.preset }}/Python | |
touch build/${{ matrix.preset }}/Python/setup.py | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat }} | |
CIBW_BEFORE_BUILD_LINUX: /bin/bash ./tools/prebuild_ql-risks.sh | |
CIBW_ENVIRONMENT: QLR_PYTHON_VERSION="${{ matrix.python }}" | |
CIBW_ENVIRONMENT_PASS_LINUX: QL_PREFIX HOST_CCACHE_DIR QLR_PYTHON_VERSION CIBUILDWHEEL=1 | |
CIBW_BEFORE_BUILD_WINDOWS: tools\prebuild_ql-risks.bat | |
CIBW_BEFORE_BUILD_MACOS: bash ./tools/prebuild_ql-risks.sh | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
CIBW_BEFORE_TEST: pip install pandas numpy matplotlib jinja2 | |
CIBW_TEST_COMMAND_WINDOWS: ${{ github.workspace }}/Python/run_tests.bat | |
CIBW_TEST_COMMAND_MACOS: bash ${{ github.workspace }}/Python/run_tests.sh | |
CIBW_TEST_COMMAND_LINUX: bash /host${{ github.workspace }}/Python/run_tests.sh | |
CIBW_BUILD_VERBOSITY: 2 | |
with: | |
package-dir: build/${{ matrix.preset }}/Python | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat }} | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
test-publish: | |
needs: build_wheels | |
if: >- | |
github.event_name == 'workflow_dispatch' || | |
(github.repository == 'auto-differentiation/QuantLib-Risks' && | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))) | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/QuantLib-Risks | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/[email protected] | |
with: | |
verbose: true | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
publish: | |
runs-on: ubuntu-latest | |
needs: test-publish | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
environment: | |
name: pypi | |
url: https://pypi.org/p/QuantLib-Risks | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/[email protected] | |
name: Publish on PyPI | |
with: | |
verbose: true | |
skip-existing: true |