-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and publish Windows Python releases. (#14575)
Fixes #13484 (hopefully, #test-in-prod) * New setup script `build_tools/python_deploy/install_windows_deps.ps1` can be used to install Python versions. GitHub Actions could use https://github.com/actions/setup-python, but I wanted to match what we have for macOS (`install_macos_deps.sh`). I tried writing this script in bash, but couldn't run the Python installer with `/quiet` for some reason, so it's written in powershell instead. Tested locally and on CI but could be brittle on other systems since Windows is Windows. * New build script `build_tools/python_deploy/build_windows_packages.sh` is forked from matching Linux and macOS scripts. Also tested this locally and on CI. These scripts can build for multiple Python versions, but I'm starting with just 3.11, which might be enough. Tested at https://github.com/openxla/iree/actions/runs/5765425296/job/15631341317, and I sanity checked that I could install and use locally built wheels.
- Loading branch information
Showing
8 changed files
with
256 additions
and
49 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
# Copyright 2023 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# build_windows_packages.sh | ||
# One stop build of IREE Python packages for Windows. This presumes that | ||
# dependencies are installed from install_windows_deps.ps1. | ||
# | ||
# Valid packages: | ||
# iree-runtime | ||
# iree-runtime-instrumented | ||
# iree-compiler | ||
|
||
set -eu -o errtrace | ||
|
||
this_dir="$(cd $(dirname $0) && pwd)" | ||
repo_root="$(cd $this_dir/../../ && pwd)" | ||
python_versions="${override_python_versions:-3.11}" | ||
output_dir="${output_dir:-${this_dir}/wheelhouse}" | ||
packages="${packages:-iree-runtime iree-runtime-instrumented iree-compiler}" | ||
|
||
# Canonicalize paths. | ||
mkdir -p "$output_dir" | ||
output_dir="$(cd $output_dir && pwd)" | ||
|
||
function run() { | ||
echo "Using python versions: ${python_versions}" | ||
|
||
local orig_path="$PATH" | ||
|
||
# Build phase. | ||
for package in $packages; do | ||
echo "******************** BUILDING PACKAGE ${package} ********************" | ||
for python_version in $python_versions; do | ||
if [[ $(py --list) != *${python_version}* ]]; then | ||
echo "ERROR: Could not find python version: ${python_version}" | ||
continue | ||
fi | ||
|
||
echo ":::: Version: $(py -${python_version} --version)" | ||
case "$package" in | ||
iree-runtime) | ||
clean_wheels iree_runtime $python_version | ||
build_iree_runtime $python_version | ||
;; | ||
iree-runtime-instrumented) | ||
clean_wheels iree_runtime_instrumented $python_version | ||
build_iree_runtime_instrumented $python_version | ||
;; | ||
iree-compiler) | ||
clean_wheels iree_compiler $python_version | ||
build_iree_compiler $python_version | ||
;; | ||
*) | ||
echo "Unrecognized package '$package'" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
done | ||
|
||
echo "******************** BUILD COMPLETE ********************" | ||
echo "Generated binaries:" | ||
ls -l $output_dir | ||
} | ||
|
||
function build_iree_runtime() { | ||
local python_version="$1" | ||
IREE_HAL_DRIVER_VULKAN=ON \ | ||
py -${python_version} -m pip wheel -v -w $output_dir $repo_root/runtime/ | ||
} | ||
|
||
function build_iree_runtime_instrumented() { | ||
local python_version="$1" | ||
IREE_HAL_DRIVER_VULKAN=ON IREE_ENABLE_RUNTIME_TRACING=ON \ | ||
IREE_RUNTIME_CUSTOM_PACKAGE_SUFFIX="-instrumented" \ | ||
py -${python_version} -m pip wheel -v -w $output_dir $repo_root/runtime/ | ||
} | ||
|
||
function build_iree_compiler() { | ||
local python_version="$1" | ||
py -${python_version} -m pip wheel -v -w $output_dir $repo_root/compiler/ | ||
} | ||
|
||
function clean_wheels() { | ||
local wheel_basename="$1" | ||
local python_version="$2" | ||
echo ":::: Clean wheels $wheel_basename $python_version" | ||
# python_version is something like "3.11", but we'd want something like "cp311". | ||
local cpython_version_string="cp${python_version%.*}${python_version#*.}" | ||
rm -f -v ${output_dir}/${wheel_basename}-*-${cpython_version_string}-*.whl | ||
} | ||
|
||
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
Oops, something went wrong.