blob: 669150345efd51f533dc4d6e68e30cfa0613bade [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.build_package }} Package"
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-2019, macos-latest]
build_package:
- py-compiler-pkg
- py-runtime-pkg
- py-xla-compiler-tools-pkg
- py-tflite-compiler-tools-pkg
- py-tf-compiler-tools-pkg
experimental: [false]
# Add experimental one off combinations below:
# include:
# - os: macos-latest
# build_package: compiler
# 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'"
# Needs the bazel manylinux image.
# TODO: Move this to our repo and pin.
CIBW_MANYLINUX_X86_64_IMAGE: stellaraccident/manylinux2014_x86_64-bazel-3.7.2:latest
# 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.build_package, 'py-compiler-pkg')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
export CIBW_BUILD="cp38-*"
package_dir="./iree-install/python_packages/iree_compiler"
export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
rm -Rf ./iree-install && \
python ./main_checkout/build_tools/cmake/cmake_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 && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
--build ./iree-build --target install-IreePythonPackage-compiler-stripped"
# 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.build_package, 'py-runtime-pkg')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
package_dir="./iree-install/python_packages/iree_rt"
export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
rm -Rf ./iree-install && \
python ./main_checkout/build_tools/cmake/cmake_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 && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
--build ./iree-build --target install-IreePythonPackage-rt-stripped"
# 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
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build XLA Compiler Tools wheels
if: "contains(matrix.build_package, 'py-xla-compiler-tools-pkg')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
export CIBW_BUILD="cp38-*"
package_dir="./iree-install/python_packages/iree_tools_xla"
export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
rm -Rf ./iree-install && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
-B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
-DCMAKE_BUILD_TYPE=Release \
-DIREE_BUILD_XLA_COMPILER=ON \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_SAMPLES=OFF && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
--build ./iree-build --target install-IreePythonPackage-tools-xla-stripped"
# 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
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build TFLite Compiler Tools wheels
if: "contains(matrix.build_package, 'py-tflite-compiler-tools-pkg')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
export CIBW_BUILD="cp38-*"
package_dir="./iree-install/python_packages/iree_tools_tflite"
export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
rm -Rf ./iree-install && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
-B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
-DCMAKE_BUILD_TYPE=Release \
-DIREE_BUILD_TFLITE_COMPILER=ON \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_SAMPLES=OFF && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
--build ./iree-build --target install-IreePythonPackage-tools-tflite-stripped"
# 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
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- name: Build TF Compiler Tools wheels
if: "contains(matrix.build_package, 'py-tf-compiler-tools-pkg')"
shell: bash
run: |
# Just need to build for one examplar python3 variant.
export CIBW_BUILD="cp38-*"
package_dir="./iree-install/python_packages/iree_tools_tf"
export CIBW_BEFORE_BUILD="rm -f ./iree-build/CMakeCache.txt && \
rm -Rf ./iree-install && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
-B./iree-build -DCMAKE_INSTALL_PREFIX=./iree-install \
-DCMAKE_BUILD_TYPE=Release \
-DIREE_BUILD_TENSORFLOW_COMPILER=ON \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_SAMPLES=OFF && \
python ./main_checkout/build_tools/cmake/cmake_ci.py \
--build ./iree-build --target install-IreePythonPackage-tools-tf-stripped"
# 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