tree: 78774894eb28e94d5b6b2766e9176f2f2994fc41 [path history] [tgz]
  1. .gitignore
  2. __init__.py
  3. BUILD.bazel
  4. common_setup.py
  5. dummy_exclude_from_package.py
  6. README.md
  7. setup_compiler.py
  8. setup_rt.py
  9. setup_tf.py
packaging/python/README.md

Python packaging scripts.

Note that packages will be placed in packaging/python/dist with the canonical instructions. However, the setup scripts can be run from anywhere and will create build and dist directories where run. Wheels can be installed with pip3 install --user dist/*.whl.

Building core wheels with CMake

Most of IREE is built/packaged with CMake. For the parts that build with CMake, this is preferred.

Canonical instructions follow:

Linux

export LDFLAGS=-fuse-ld=/usr/bin/ld.lld
export PYIREE_CMAKE_BUILD_ROOT="${HOME?}/build-iree-release"
export IREE_SRC="${HOME?}/src/iree"
rm -Rf "${PYIREE_CMAKE_BUILD_ROOT?}"; mkdir -p "${PYIREE_CMAKE_BUILD_ROOT?}"
cmake -GNinja -B"${PYIREE_CMAKE_BUILD_ROOT?}" -H"${IREE_SRC}" \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DIREE_BUILD_PYTHON_BINDINGS=ON -DIREE_BUILD_SAMPLES=OFF
(cd "${PYIREE_CMAKE_BUILD_ROOT?}" && ninja)
(cd "${IREE_SRC?}/packaging/python" && (
  rm -Rf build;
  python3 setup_compiler.py bdist_wheel;
  rm -Rf build;
  python3 setup_rt.py bdist_wheel))

Building IREE/TensorFlow wheels

If building TensorFlow integration wheels, then this must be done via Bazel. In this case, it can be easiest to just package everything from a Bazel build to avoid multiple steps.

Canonical instructions follow:

Env Setup

IREE_SRC=$HOME/src/iree
export PYIREE_BAZEL_BUILD_ROOT="$IREE_SRC/bazel-bin"
if which cygpath; then
  export PYIREE_BAZEL_BUILD_ROOT="$(cygpath -w "$PYIREE_BAZEL_BUILD_ROOT")"
fi

Building:

Optionally add: --define=PYIREE_TF_DISABLE_KERNELS=1 to build a ‘thin’ (less functional) version without TensorFlow kernels. This should not be done for released binaries but can help while developing.

cd $IREE_SRC
bazel build -c opt \
  //packaging/python:all_pyiree_packages

Packaging

(cd $IREE_SRC/packaging/python && (
  rm -Rf build;
  python3 setup_tf.py bdist_wheel))
(cd $IREE_SRC/packaging/python && (
  rm -Rf build;
  python3 setup_compiler.py bdist_wheel))
(cd $IREE_SRC/packaging/python && (
  rm -Rf build;
  python3 setup_rt.py bdist_wheel))