Skip to content

Workflow file for this run

name: Build 🐍 📦 + Publish to PyPI
on:
push:
workflow_dispatch:
jobs:
build_wheels:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
# tag '2023.04.15'
vcpkgCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
triplet: 'x64-linux-dynamic'
- os: macos-latest
# tag '2023.04.15'
vcpkgCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
triplet: 'x64-osx-dynamic'
- os: windows-latest
# tag '2023.04.15'
vcpkgCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
triplet: 'x64-windows'
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Special case: cibuildwheel uses docker container for
# manylinux builds, so cache our vcpkg data on the
# host filesystem (mounted to /host by default)
- name: Point VCPKG_BINARY_SOURCES to host filesystem (Linux only)
if: runner.os == 'Linux'
run: |
echo "VCPKG_BINARY_SOURCES=/host/${RUNNER_WORKSPACE}/b/vcpkg_cache" >> $GITHUB_ENV
shell: bash
- name: run vcpkg
uses: lukka/run-vcpkg@main
id: run_vcpkg
with:
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}'
# 'runVcpkgInstall=false' is especially important in the case of Linux -
# we need the cibuildwheel Docker container to actually build/install
# the dependencies, even if they are stored on the host filesystem
# (exposed via the /host mount point) and cached by the host runner.
runVcpkgInstall: false
vcpkgJsonGlob: '**/build-scripts/vcpkg.json'
- name: List $RUNNER_WORKSPACE before build
run: find $RUNNER_WORKSPACE
shell: bash
- name: Normalize paths (Windows only)
if: runner.os == 'Windows'
run: |
echo "UNIX_RUNNER_WORKSPACE=${RUNNER_WORKSPACE//\\//}" >> $GITHUB_ENV
echo "UNIX_GITHUB_WORKSPACE=${GITHUB_WORKSPACE//\\//}" >> $GITHUB_ENV
shell: bash
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.1
env:
CIBW_ENVIRONMENT_WINDOWS: >-
CMAKE_ARGS='
-DCMAKE_TOOLCHAIN_FILE=${{ env.UNIX_RUNNER_WORKSPACE }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DVCPKG_INSTALLED_DIR=${{ env.UNIX_RUNNER_WORKSPACE }}/b/vcpkg_installed
-DVCPKG_MANIFEST_DIR=${{ env.UNIX_GITHUB_WORKSPACE }}/build-scripts
-DUPSP_BUILD_TESTING=OFF -DUPSP_BUILD_APPLICATIONS=OFF -DUPSP_BUILD_PYBIND11=ON'
CIBW_ENVIRONMENT_MACOS: >-
CMAKE_ARGS='
-DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DVCPKG_INSTALLED_DIR=${{ runner.workspace }}/b/vcpkg_installed
-DVCPKG_MANIFEST_DIR=${{ github.workspace }}/build-scripts
-DUPSP_BUILD_TESTING=OFF -DUPSP_BUILD_APPLICATIONS=OFF -DUPSP_BUILD_PYBIND11=ON'
CIBW_ENVIRONMENT_LINUX: >-
CMAKE_ARGS='
-DCMAKE_TOOLCHAIN_FILE=/host/${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DVCPKG_INSTALLED_DIR=/host/${{ runner.workspace }}/b/vcpkg_installed
-DVCPKG_MANIFEST_DIR=/host/${{ github.workspace }}/build-scripts
-DUPSP_BUILD_TESTING=OFF -DUPSP_BUILD_APPLICATIONS=OFF -DUPSP_BUILD_PYBIND11=ON'
CIBW_BEFORE_ALL_LINUX: "yum install -y perl-IPC-Cmd zip ninja-build"
CIBW_BEFORE_BUILD_WINDOWS: "pip install cmake"
CIBW_BUILD: "cp*-win_amd64 cp*-macosx_x86_64 cp*-manylinux_x86_64"
CIBW_SKIP: "*-win32 *-manylinux_i686"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: "pytest {project}/test/python"
with:
package-dir: .
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # for setuptools_scm
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
pypi_publish:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
# Upload for any push of tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
# For testing
# with:
# repository_url: https://test.pypi.org/legacy/