Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/actions/build-wheel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Build wheel
description: Build, retag, repair, and upload a wheel for one platform.

inputs:
package:
required: true
platform:
required: true
artifact-name:
required: true
container:
required: false
default: ""
docker-image:
required: false
default: ""
manylinux-plat:
required: false
default: ""
msvc-arch:
required: false
default: ""
wheel-plat:
required: false
default: ""
pin-gcc12:
required: false
default: "false"
toolchain:
required: false
default: ""
llvm-ref:
required: false
default: ""

runs:
using: composite
steps:
- name: Set up GCC 12 and Python (manylinux)
if: inputs.container != ''
shell: bash
run: |
yum install -y gcc-toolset-12-gcc-c++
echo "/opt/rh/gcc-toolset-12/root/usr/bin" >> "$GITHUB_PATH"
echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH"

- name: Set up Python
if: inputs.container == '' && inputs.docker-image == ''
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up MSVC
if: inputs.msvc-arch != ''
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ inputs.msvc-arch }}

- name: Build wheel
if: inputs.docker-image == ''
shell: bash
env:
PACKAGE: ${{ inputs.package }}
TOOLCHAIN: ${{ inputs.toolchain }}
HALIDE_LLVM_REF: ${{ inputs.llvm-ref }}
run: |
pip install cmake ninja
arguments=("$PACKAGE" -w dist/ -v)
if [[ -n "$TOOLCHAIN" ]]; then
arguments+=("--config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/$PACKAGE/toolchains/$TOOLCHAIN")
fi
pip wheel "${arguments[@]}"

- name: Build wheel (docker)
if: inputs.docker-image != ''
shell: bash
env:
PACKAGE: ${{ inputs.package }}
DOCKER_IMAGE: ${{ inputs.docker-image }}
PIN_GCC12: ${{ inputs.pin-gcc12 }}
TOOLCHAIN: ${{ inputs.toolchain }}
HALIDE_LLVM_REF: ${{ inputs.llvm-ref }}
GITHUB_TOKEN: ${{ github.token }}
run: |
docker run --rm -v "${{ github.workspace }}:/project" -w /project \
-e PACKAGE -e TOOLCHAIN -e HALIDE_LLVM_REF -e GITHUB_TOKEN -e PIN_GCC12 \
"$DOCKER_IMAGE" bash -c '
set -euo pipefail
if [ "$PIN_GCC12" = true ]; then
yum install -y gcc-toolset-12-gcc-c++;
export PATH="/opt/rh/gcc-toolset-12/root/usr/bin:$PATH";
fi
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip install cmake ninja
arguments=("$PACKAGE" -w dist/ -v)
if [ -n "$TOOLCHAIN" ]; then
arguments+=("--config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE=/project/$PACKAGE/toolchains/$TOOLCHAIN")
fi
pip wheel "${arguments[@]}"
'

- name: Retag wheel
if: inputs.wheel-plat != ''
shell: bash
run: |
pip install wheel
wheel tags --platform-tag ${{ inputs.wheel-plat }} --remove dist/*.whl

- name: Repair wheel (auditwheel)
if: inputs.manylinux-plat != '' && inputs.docker-image == ''
shell: bash
run: |
pip install auditwheel
bash scripts/repair-wheel.sh ${{ inputs.manylinux-plat }} dist

- name: Repair wheel (auditwheel/docker)
if: inputs.manylinux-plat != '' && inputs.docker-image != ''
shell: bash
env:
DOCKER_IMAGE: ${{ inputs.docker-image }}
run: |
docker run --rm -v "${{ github.workspace }}:/project" -w /project \
"$DOCKER_IMAGE" bash -c '
set -euo pipefail
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip install auditwheel
bash scripts/repair-wheel.sh ${{ inputs.manylinux-plat }} dist
'

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: dist/*.whl
93 changes: 10 additions & 83 deletions .github/workflows/build-dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,90 +44,17 @@ jobs:
with:
submodules: recursive

- name: Set up GCC 12 and Python (manylinux)
if: matrix.container
run: |
yum install -y gcc-toolset-12-gcc-c++
echo "/opt/rh/gcc-toolset-12/root/usr/bin" >> "$GITHUB_PATH"
echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH"

- name: Set up Python
if: ${{ !matrix.container && !matrix.docker_image }}
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up MSVC
if: matrix.msvc_arch
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}

- name: Install CMake and Ninja
if: ${{ !matrix.container && !matrix.docker_image }}
run: pip install cmake ninja

- name: Build wheel
if: ${{ !matrix.docker_image }}
run: pip wheel ${{ inputs.package }} -w dist/

- name: Build wheel (docker)
if: matrix.docker_image
run: |
docker run --rm -v "${{ github.workspace }}:/project" -w /project \
-e PIN_GCC12=${{ matrix.pin_gcc12 && 'true' || 'false' }} \
${{ matrix.docker_image }} bash -c '
set -euo pipefail
if [ "$PIN_GCC12" = true ]; then
yum install -y gcc-toolset-12-gcc-c++
export PATH="/opt/rh/gcc-toolset-12/root/usr/bin:$PATH"
fi
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip install cmake ninja
pip wheel ${{ inputs.package }} -w dist/
'

- name: Retag wheel
if: matrix.wheel_plat
shell: bash
run: |
pip install wheel
wheel tags --platform-tag ${{ matrix.wheel_plat }} --remove dist/*.whl

- name: Repair wheel (auditwheel)
if: ${{ matrix.manylinux_plat && !matrix.docker_image }}
run: |
pip install auditwheel
OUTPUT=$(auditwheel repair --plat ${{ matrix.manylinux_plat }} -w dist/ dist/*.whl 2>&1) || {
echo "$OUTPUT"
echo "$OUTPUT" | grep -q "does not look like a platform wheel" \
&& pip install wheel && wheel tags --platform-tag ${{ matrix.manylinux_plat }} --remove dist/*.whl \
|| exit 1
}
rm -f dist/*-linux_*.whl

- name: Repair wheel (auditwheel/docker)
if: ${{ matrix.manylinux_plat && matrix.docker_image }}
run: |
docker run --rm -v "${{ github.workspace }}:/project" -w /project \
${{ matrix.docker_image }} bash -c '
set -euo pipefail
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip install auditwheel
OUTPUT=$(auditwheel repair --plat ${{ matrix.manylinux_plat }} -w dist/ dist/*.whl 2>&1) || {
echo "$OUTPUT"
echo "$OUTPUT" | grep -q "does not look like a platform wheel" \
&& pip install wheel && wheel tags --platform-tag ${{ matrix.manylinux_plat }} --remove dist/*.whl \
|| exit 1
}
rm -f dist/*-linux_*.whl
'

- name: Upload wheel
uses: actions/upload-artifact@v4
- uses: ./.github/actions/build-wheel
with:
name: wheel-${{ matrix.pkg }}-${{ matrix.platform }}
path: dist/*.whl
package: ${{ inputs.package }}
platform: ${{ matrix.platform }}
artifact-name: wheel-${{ matrix.pkg }}-${{ matrix.platform }}
container: ${{ matrix.container }}
docker-image: ${{ matrix.docker_image }}
manylinux-plat: ${{ matrix.manylinux_plat }}
msvc-arch: ${{ matrix.msvc_arch }}
wheel-plat: ${{ matrix.wheel_plat }}
pin-gcc12: ${{ matrix.pin_gcc12 }}

publish:
name: Publish dependency release
Expand Down
132 changes: 15 additions & 117 deletions .github/workflows/build-llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
outputs:
should_build: ${{ steps.check.outputs.should_build }}
llvm_ref: ${{ steps.check.outputs.llvm_ref }}
matrix: ${{ steps.check.outputs.matrix }}
steps:
- uses: actions/checkout@v4

Expand All @@ -44,47 +45,7 @@ jobs:
contents: read
strategy:
fail-fast: false
matrix:
include:
- platform: x86-64-linux
runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_28_x86_64
toolchain: x86-64-linux.cmake
manylinux_plat: manylinux_2_28_x86_64
- platform: x86-32-linux
runner: ubuntu-latest
toolchain: x86-32-linux.cmake
docker_image: quay.io/pypa/manylinux_2_28_i686
manylinux_plat: manylinux_2_28_i686
pin_gcc12: true
- platform: arm-64-linux
runner: ubuntu-24.04-arm
container: quay.io/pypa/manylinux_2_28_aarch64
toolchain: arm-64-linux.cmake
manylinux_plat: manylinux_2_28_aarch64
- platform: arm-32-linux
runner: ubuntu-24.04-arm
toolchain: arm-32-linux.cmake
docker_image: quay.io/pypa/manylinux_2_31_armv7l
manylinux_plat: manylinux_2_31_armv7l
- platform: x86-64-macos
runner: macos-15-intel
toolchain: x86-64-macos.cmake
- platform: arm-64-macos
runner: macos-15
toolchain: arm-64-macos.cmake
- platform: x86-64-windows
runner: windows-2022
toolchain: x86-64-windows.cmake
msvc_arch: amd64
- platform: x86-32-windows
runner: windows-2022
toolchain: x86-32-windows.cmake
msvc_arch: amd64_x86
wheel_plat: win32
defaults:
run:
working-directory: packages/halide-llvm
matrix: ${{ fromJSON(needs.check.outputs.matrix) }}
env:
HALIDE_LLVM_REF: ${{ needs.check.outputs.llvm_ref }}
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -95,83 +56,20 @@ jobs:

# Keep GCC 12 for manylinux builds: newer libstdc++ symbols are not
# repaired by auditwheel and break consumers with older toolchains.
- name: Set up GCC 12 and Python (manylinux)
if: matrix.container
run: |
yum install -y gcc-toolset-12-gcc-c++
echo "/opt/rh/gcc-toolset-12/root/usr/bin" >> "$GITHUB_PATH"
echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH"

- name: Set up Python
if: ${{ !matrix.container && !matrix.docker_image }}
uses: actions/setup-python@v5
with:
python-version: "3.12"

# VS 2022 is intentionally pinned to match the toolset used by Halide.
- name: Set up MSVC
if: matrix.msvc_arch
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}

- name: Build wheel
if: ${{ !matrix.docker_image }}
run: >
pip wheel . -w dist/ -v
--config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE=toolchains/${{ matrix.toolchain }}

- name: Retag wheel
if: matrix.wheel_plat
shell: bash
run: |
pip install wheel
wheel tags --platform-tag ${{ matrix.wheel_plat }} --remove dist/*.whl

# i686 and armv7l use Docker because the manylinux images cannot run
# actions/checkout's Node runtime on those architectures.
- name: Build wheel (docker)
if: matrix.docker_image
run: |
docker run --rm \
-v "${{ github.workspace }}:/project" \
-w /project/packages/halide-llvm \
-e HALIDE_LLVM_REF -e GITHUB_TOKEN \
-e PIN_GCC12=${{ matrix.pin_gcc12 && 'true' || 'false' }} \
${{ matrix.docker_image }} bash -c '
set -euo pipefail
if [ "$PIN_GCC12" = true ]; then
yum install -y gcc-toolset-12-gcc-c++
export PATH="/opt/rh/gcc-toolset-12/root/usr/bin:$PATH"
fi
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip wheel . -w dist/ -v --config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE=toolchains/${{ matrix.toolchain }}
'

- name: Repair wheel (auditwheel)
if: ${{ matrix.manylinux_plat && !matrix.docker_image }}
run: |
pip install auditwheel
auditwheel repair --plat ${{ matrix.manylinux_plat }} -w dist/ dist/*.whl
rm -f dist/*-linux_*.whl

- name: Repair wheel (auditwheel/docker)
if: ${{ matrix.manylinux_plat && matrix.docker_image }}
run: |
docker run --rm -v "${{ github.workspace }}:/project" \
-w /project/packages/halide-llvm ${{ matrix.docker_image }} bash -c '
set -euo pipefail
export PATH="/opt/python/cp312-cp312/bin:$PATH"
pip install auditwheel
auditwheel repair --plat ${{ matrix.manylinux_plat }} -w dist/ dist/*.whl
rm -f dist/*-linux_*.whl
'

- name: Upload wheel
uses: actions/upload-artifact@v4
# VS 2022 remains pinned through the canonical LLVM matrix.
- uses: ./.github/actions/build-wheel
with:
name: wheel-${{ matrix.platform }}
path: packages/halide-llvm/dist/*.whl
package: packages/halide-llvm
platform: ${{ matrix.platform }}
artifact-name: wheel-${{ matrix.pkg }}-${{ matrix.platform }}
container: ${{ matrix.container }}
docker-image: ${{ matrix.docker_image }}
manylinux-plat: ${{ matrix.manylinux_plat }}
msvc-arch: ${{ matrix.msvc_arch }}
wheel-plat: ${{ matrix.wheel_plat }}
pin-gcc12: ${{ matrix.pin_gcc12 }}
toolchain: ${{ matrix.toolchain }}
llvm-ref: ${{ needs.check.outputs.llvm_ref }}

publish:
name: Publish LLVM release
Expand Down
Loading
Loading