Update pip.yml #596
Workflow file for this run
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
# Relevant GHA docs links: | |
# https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container | |
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio | |
name: Build PyPI nightlies | |
on: | |
push: | |
branches: [ main, srj/pypi-try ] | |
release: | |
types: [ created ] | |
env: | |
# TODO: these don't need to be env vars, is there another way? | |
LLVM_VER_MAJOR: 17 | |
LLVM_VER_MINOR: 0 | |
LLVM_VER_PATCH: 6 | |
LLVM_VER: ${LLVM_VER_MAJOR}.${LLVM_VER_MINOR}.${LLVM_VER_PATCH} | |
HALIDE_CMAKE_OPTS: -DCMAKE_BUILD_TYPE=Release -DWITH_DOCS=NO -DWITH_PYTHON_BINDINGS=NO -DWITH_PYTHON_STUBS=NO -DWITH_TESTS=NO -DWITH_TUTORIALS=NO -DWITH_UTILS=NO | |
DEV_PREFIX: b | |
MANYLINUX_INSTALL_DISTRO: bionic | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
packages: read # to fetch packages (docker) | |
jobs: | |
pip-all: | |
name: Package Halide Python bindings | |
runs-on: ${{ matrix.buildplat[0] }} | |
concurrency: | |
group: pip-all-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ matrix.python }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
packages: read # to fetch packages (docker) | |
strategy: | |
fail-fast: false | |
matrix: | |
# python: [ cp38, cp39, cp310, cp311, cp312 ] | |
python: [ cp311 ] | |
buildplat: | |
# [runner, pytag, arch] | |
- [ubuntu-22.04, manylinux_x86_64, x86_64] | |
- [ubuntu-22.04, manylinux_aarch64, aarch64] | |
# - [macos-12, macosx_universal2, arm64;x86_64] | |
# - [windows-2022, win_amd64, x64] | |
steps: | |
- uses: actions/checkout@v4 | |
# cibuildwheel is confused by the presence of the .so | |
# prebuilts for Hexagon and considers them an error. | |
# Just pre-emptively remove them to avoid this. | |
- name: Remove Hexagon prebuilts | |
shell: bash | |
run: rm -rf src/runtime/hexagon_remote/bin/ | |
# ---------- Linux-specific LLVM stuff | |
# - name: Log in to GitHub Container Registry | |
# if: runner.os == 'Linux' | |
# uses: docker/login-action@v3 | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
# ---------- non-Linux-specific LLVM stuff | |
- name: Cache LLVM build folder | |
if: runner.os != 'Linux' | |
id: cache-llvm | |
uses: actions/[email protected] | |
with: | |
path: local-llvm | |
key: llvmorg-${{ env.LLVM_VER }}-${{ runner.os }}-${{ runner.arch }} | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- uses: lukka/get-cmake@latest | |
- uses: actions/checkout@v4 | |
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true' | |
with: | |
path: llvm-src | |
repository: llvm/llvm-project | |
ref: llvmorg-${{ env.LLVM_VER }} | |
- name: Configure LLVM | |
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true' | |
run: > | |
cmake -G Ninja -S llvm-src/llvm -B llvm-build | |
-DCMAKE_BUILD_TYPE=Release | |
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" | |
-DLLVM_ENABLE_ASSERTIONS=ON | |
-DLLVM_ENABLE_BINDINGS=OFF | |
-DLLVM_ENABLE_CURL=OFF | |
-DLLVM_ENABLE_DIA_SDK=OFF | |
-DLLVM_ENABLE_EH=ON | |
-DLLVM_ENABLE_HTTPLIB=OFF | |
-DLLVM_ENABLE_IDE=OFF | |
-DLLVM_ENABLE_LIBXML2=OFF | |
-DLLVM_ENABLE_OCAMLDOC=OFF | |
"-DLLVM_ENABLE_PROJECTS=clang;lld" | |
-DLLVM_ENABLE_RTTI=ON | |
-DLLVM_ENABLE_TERMINFO=OFF | |
-DLLVM_ENABLE_WARNINGS=OFF | |
-DLLVM_ENABLE_ZLIB=OFF | |
-DLLVM_ENABLE_ZSTD=OFF | |
-DLLVM_INCLUDE_BENCHMARKS=OFF | |
-DLLVM_INCLUDE_EXAMPLES=OFF | |
-DLLVM_INCLUDE_TESTS=OFF | |
"-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Hexagon;PowerPC;WebAssembly" | |
- name: Build LLVM | |
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true' | |
run: cmake --build llvm-build | |
- name: Install LLVM | |
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true' | |
run: cmake --install llvm-build --prefix local-llvm | |
# Remove the LLVM source tree after building it, otherwise we can | |
# run out of local space while building halide | |
- name: Clean LLVM Source | |
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true' | |
shell: bash | |
run: rm -rf llvm-src | |
# ------------------------ Build Halide | |
- name: Configure Halide (Windows) | |
if: runner.os == 'Windows' | |
run: > | |
cmake -G "Visual Studio 17 2022" -T ClangCL -A "${{ matrix.buildplat[2] }}" -S . -B halide-build | |
${{ env.HALIDE_CMAKE_OPTS }} | |
-DLLVM_DIR=${{ github.workspace }}/local-llvm/lib/cmake/llvm | |
- name: Configure Halide (macOS) | |
if: runner.os == 'macOS' | |
run: > | |
cmake -G Ninja -S . -B halide-build | |
${{ env.HALIDE_CMAKE_OPTS }} | |
"-DCMAKE_OSX_ARCHITECTURES=${{ matrix.buildplat[2] }}" | |
-DLLVM_DIR=${{ github.workspace }}/local-llvm/lib/cmake/llvm | |
- name: Build Halide | |
if: runner.os != 'Linux' | |
run: cmake --build halide-build --target install --config Release | |
- name: Install Halide | |
if: runner.os != 'Linux' | |
run: cmake --install halide-build --config Release --prefix local-halide | |
- name: Build Wheels | |
uses: pypa/[email protected] | |
env: | |
CMAKE_PREFIX_PATH: ${{ github.workspace }}/local-halide | |
CIBW_ARCHS_LINUX: "${{ matrix.buildplat[2] }}" | |
CIBW_ARCHS_MACOS: "universal2" | |
CIBW_BUILD: "${{ matrix.python }}-${{ matrix.buildplat[1] }}" | |
CIBW_CONFIG_SETTINGS: --global-option=egg_info --global-option=--tag-build=${{ env.DEV_PREFIX }} --global-option=--tag-date | |
CIBW_BEFORE_ALL_LINUX: | | |
sudo apt-get install wget && \ | |
which wget && \ | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \ | |
sudo add-apt-repository "deb http://apt.llvm.org/${{ env.MANYLINUX_INSTALL_DISTRO }}/ llvm-toolchain-${{ env.MANYLINUX_INSTALL_DISTRO }}-${{ env.LLVM_VER_MAJOR }} main" && \ | |
sudo apt-get install libllvm${{ env.LLVM_VER_MAJOR }} llvm-${{ env.LLVM_VER_MAJOR }} llvm-${{ env.LLVM_VER_MAJOR }}-dev llvm-${{ env.LLVM_VER_MAJOR }}-runtime libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev libfuzzer-${{ env.LLVM_VER_MAJOR }}-dev lld-18 libc++-${{ env.LLVM_VER_MAJOR }}-dev libc++abi-${{ env.LLVM_VER_MAJOR }}-dev libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm64 libc++-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libc++abi-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm64 libclang-${{ env.LLVM_VER_MAJOR }}-dev libzstd-dev liblld-${{ env.LLVM_VER_MAJOR }} liblld-${{ env.LLVM_VER_MAJOR }}-dev && \ | |
cmake -G Ninja -S . -B halide-build ${{ env.HALIDE_CMAKE_OPTS }} && \ | |
cmake --build halide-build --target install --config Release && \ | |
cmake --install halide-build --config Release --prefix local-halide | |
# CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/halide/manylinux2014_x86_64-llvm:${{ env.LLVM_VER }} | |
# CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/halide/manylinux2014_aarch64-llvm:${{ env.LLVM_VER }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels | |
path: ./wheelhouse/*.whl | |
publish: | |
name: Publish on PyPI | |
needs: [ pip-all ] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_TOKEN }} | |
repository_url: https://test.pypi.org/legacy/ | |
verbose: true | |
# - uses: pypa/[email protected] | |
# if: github.event_name == 'release' && github.event.action == 'published' | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.PYPI_TOKEN }} |