blob: 029ef35b5a828314837abd003b4803b700549e11 [file] [log] [blame]
# Builds packages for native (non cross-compiled) targets on supported
# platforms.
#
# For these mainline distributions, we use cibuildwheel and drive the
# packaging through python, extracting native assets. While this may seem
# hopelessly round-about, it lets us leverage a lot of what cibuildwheel
# does for free and get python packages to boot.
name: Build Native Release Packages
on:
workflow_dispatch:
inputs:
package_suffix:
description: 'Suffix to append to package names'
required: true
default: '-cidev'
package_version:
description: 'Version of the package'
required: true
default: '0.1a1'
release_id:
description: 'Release id to upload artifacts to'
default: ''
jobs:
build_core:
name: "${{ matrix.os }} :: Build ${{ matrix.python_package }} Package"
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
python_package: [compiler, runtime]
experimental: [false]
# include:
# - os: macos-latest
# experimental: true
# - os: windows-2019
# experimental: true
env:
CIBW_BUILD_VERBOSITY: 1
# Note that on Linux, we run under docker with an altered path.
CIBW_ENVIRONMENT_LINUX: "REPO_DIR=/project/main_checkout"
CIBW_ENVIRONMENT_MACOS: "REPO_DIR=${{ github.workspace }}/main_checkout"
CIBW_ENVIRONMENT_WINDOWS: "REPO_DIR='${{ github.workspace }}\\main_checkout'"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
CIBW_SKIP: "*-win32 *-manylinux_i686"
steps:
- uses: actions/checkout@v2
with:
path: 'main_checkout'
submodules: true
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'
- name: Write version info
shell: bash
run: |
cat << EOF > ./main_checkout/version_info.json
{
"package-suffix": "${{ github.event.inputs.package_suffix }}",
"package-version": "${{ github.event.inputs.package_version }}",
"iree-revision": "$(cd ./main_checkout && git rev-parse HEAD)"
}
EOF
cat ./main_checkout/version_info.json
- name: Install cibuildwheel
shell: bash
run: |
python -m pip install cibuildwheel==1.7.2
# Compiler wheels are not python version specific, so we just shard and
# build once for an examplar version of python. This could save a bit of
# time by not building IREE's runtime, but it is small compared to
# the compiler build.
- name: Build compiler wheels
if: "contains(matrix.python_package, 'compiler')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
export CIBW_BUILD="cp38-*"
package_dir="./install-iree/python_packages/iree_compiler"
export CIBW_BEFORE_BUILD="rm -f ./build-iree/CMakeCache.txt && \
rm -Rf ./install-iree && \
python ./main_checkout/build_tools/cmake/cmake_configure_ci.py \
-B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
-DCMAKE_BUILD_TYPE=Release \
-DIREE_BUILD_COMPILER=ON \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_SAMPLES=OFF && \
cmake --build ./iree-build --target install/strip"
# TODO: cibuildwheel sanity checks this, but our setup.py is the
# *output* of the build :( File a bug.
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir wheelhouse $package_dir
# Runtime wheels are version specific, so we build one for each python
# version. We do this serially by deleting the CMakeCache and install
# directory between runs. Most of the build will be incremental.
# We save a little bit of time by disabling the compiler build.
- name: Build runtime wheels
if: "contains(matrix.python_package, 'runtime')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
package_dir="./install-iree/python_packages/iree_rt"
export CIBW_BEFORE_BUILD="rm -f ./build-iree/CMakeCache.txt && \
rm -Rf ./install-iree && \
python ./main_checkout/build_tools/cmake/cmake_configure_ci.py \
-B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
-DCMAKE_BUILD_TYPE=Release \
-DIREE_BUILD_COMPILER=OFF \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_SAMPLES=OFF && \
cmake --build ./iree-build --target install/strip"
# TODO: cibuildwheel sanity checks this, but our setup.py is the
# *output* of the build :( File a bug.
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir wheelhouse $package_dir
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
retention-days: 5
- name: Upload Release Assets
if: github.event.inputs.release_id != ''
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_WRITE_ACCESS_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
assets_path: ./wheelhouse/*.whl