Skip to content

Commit

Permalink
Add pip packaging workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinking committed Oct 7, 2022
1 parent e85b880 commit 617870a
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 70 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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 package

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
build-halide:
name: Build Halide

runs-on: ubuntu-latest

strategy:
matrix:
arch: [ x86_64, i686, aarch64 ]

steps:
- uses: actions/checkout@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.10.2
env:
CIBW_ARCHS_LINUX: "${{ matrix.arch }}"
CIBW_BUILD: "cp38-manylinux* cp39-manylinux* cp310-manylinux*"
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/halide/manylinux2014_x86_64-llvm:15.0.1
CIBW_MANYLINUX_I686_IMAGE: ghcr.io/halide/manylinux2014_i686-llvm:15.0.1
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/halide/manylinux2014_aarch64-llvm:15.0.1
CIBW_BEFORE_ALL_LINUX: >
cmake -G Ninja -S . -B build
-DCMAKE_BUILD_TYPE=Release -DWITH_DOCS=NO -DWITH_PYTHON_BINDINGS=NO -DWITH_TESTS=NO
-DWITH_TUTORIALS=NO -DWITH_UTILS=NO &&
cmake --build build --target install
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
graft python_bindings
prune python_bindings/test
prune python_bindings/tutorial
17 changes: 17 additions & 0 deletions build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

export CIBW_PLATFORM=linux

export CIBW_ARCHS="x86_64 i686 aarch64"
export CIBW_BUILD="cp38-manylinux* cp39-manylinux* cp310-manylinux*"

export CIBW_MANYLINUX_X86_64_IMAGE=ghcr.io/halide/manylinux2014_x86_64-llvm:15.0.1
export CIBW_MANYLINUX_I686_IMAGE=ghcr.io/halide/manylinux2014_i686-llvm:15.0.1
export CIBW_MANYLINUX_AARCH64_IMAGE=ghcr.io/halide/manylinux2014_aarch64-llvm:15.0.1

export CIBW_BEFORE_ALL="\
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_DOCS=NO -DWITH_PYTHON_BINDINGS=NO -DWITH_TESTS=NO \
-DWITH_TUTORIALS=NO -DWITH_UTILS=NO && \
cmake --build build --target install"

cibuildwheel --print-build-identifiers
2 changes: 1 addition & 1 deletion python_bindings/pyproject.toml → pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"setuptools>=43",
"wheel",
"scikit-build",
"pybind11==2.6.2",
Expand Down
14 changes: 0 additions & 14 deletions python_bindings/requirements.txt

This file was deleted.

55 changes: 0 additions & 55 deletions python_bindings/setup.py

This file was deleted.

11 changes: 11 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake>=3.22
imageio
ninja; platform_system!='Windows'
numpy
pillow
pybind11==2.6.2
scikit-build
scipy
setuptools>=43
wheel
build
26 changes: 26 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pybind11
from setuptools import find_packages
from skbuild import setup

setup(
name="halide",
version='15.0.0',
author="The Halide team",
author_email="",
description="",
long_description="",
python_requires=">=3.6",
packages=find_packages(where="python_bindings/src"),
package_dir={"": "python_bindings/src"},
cmake_source_dir="python_bindings",
cmake_args=[
f"-Dpybind11_ROOT={pybind11.get_cmake_dir()}",
"-DCMAKE_REQUIRE_FIND_PACKAGE_pybind11=YES",
"-DHalide_INSTALL_PYTHONDIR=python_bindings/src",
"-DCMAKE_INSTALL_RPATH=$<IF:$<PLATFORM_ID:Darwin>,@loader_path,$ORIGIN>",
"-DHalide_Python_INSTALL_IMPORTED_DEPS=ON",
"-DWITH_TESTS=NO",
"-DWITH_TUTORIALS=NO",
"--no-warn-unused-cli",
],
)

0 comments on commit 617870a

Please sign in to comment.