Fix macOS package build (#3562)

Without `--no-build-isolation` pip invokes `setup.py` in fresh
environment, which doesn't have `torch` installed. But `setup.py` does
`import torch` to check PyTorch version, so the build crashes. At the
same time the script creates a disposable virtual environment with all
required dependencies specifically to run wheel build. Note that Linux
package build also runs with this option.


15cf7106c4/setup.py (L230)

This was introduced by this commit:
74f7a0c9d6

And looks like macOS builds were not running in CI ever since.

I also updated Python versions in `install_macos_deps.sh`.
pull/3636/merge
Dmitry Babokin 2024-08-22 06:43:20 -07:00 committed by GitHub
parent 4358aaccd6
commit a980130676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -6,7 +6,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# build_macos_packages.sh
# One stop build of IREE Python packages for MacOS. This presumes that
# One stop build of torch-mlir Python packages for MacOS. This presumes that
# dependencies are installed from install_macos_deps.sh. This will build
# for a list of Python versions synchronized with that script and corresponding
# with directory names under:
@ -30,7 +30,7 @@ echo "Setting torch-mlir Python Package version to: ${TORCH_MLIR_PYTHON_PACKAGE_
# Note that this typically is selected to match the version that the official
# Python distributed is built at.
export MACOSX_DEPLOYMENT_TARGET="${TORCH_MLIR_OSX_TARGET:-11.0}"
export MACOSX_DEPLOYMENT_TARGET="${TORCH_MLIR_OSX_TARGET:-11.1}"
export CMAKE_OSX_ARCHITECTURES="${TORCH_MLIR_OSX_ARCH:-arm64;x86_64}"
echo "CMAKE_OSX_ARCHITECTURES: $CMAKE_OSX_ARCHITECTURES"
echo "MACOSX_DEPLOYMENT_TARGET $MACOSX_DEPLOYMENT_TARGET"
@ -88,7 +88,7 @@ function build_torch_mlir() {
TORCH_MLIR_PYTHON_PACKAGE_VERSION=${TORCH_MLIR_PYTHON_PACKAGE_VERSION} \
MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
CMAKE_OSX_ARCHITECTURES=$CMAKE_OSX_ARCHITECTURES \
python"${python_version}" -m pip wheel -v -w "$output_dir" "$repo_root" --extra-index-url https://download.pytorch.org/whl/nightly/cpu
python"${python_version}" -m pip wheel -v --no-build-isolation -w "$output_dir" "$repo_root" --extra-index-url https://download.pytorch.org/whl/nightly/cpu
deactivate
rm -rf "$output_dir"/build_venv
}
@ -107,7 +107,7 @@ function build_torch_mlir_core() {
CMAKE_OSX_ARCHITECTURES=$CMAKE_OSX_ARCHITECTURES \
TORCH_MLIR_ENABLE_JIT_IR_IMPORTER=0 \
TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS=1 \
python"${python_version}" -m pip wheel -v -w "$output_dir" "$repo_root"
python"${python_version}" -m pip wheel -v --no-build-isolation -w "$output_dir" "$repo_root"
deactivate
rm -rf "$output_dir"/build_venv
}

View File

@ -19,14 +19,14 @@ if [[ "$(whoami)" != "root" ]]; then
fi
PYTHON_INSTALLER_URLS=(
"https://www.python.org/ftp/python/3.11.2/python-3.11.2-macos11.pkg"
"https://www.python.org/ftp/python/3.10.10/python-3.10.10-macos11.pkg"
"https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg"
"https://www.python.org/ftp/python/3.10.11/python-3.10.11-macos11.pkg"
"https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg"
)
PYTHON_SPECS=(
3.11@https://www.python.org/ftp/python/3.11.2/python-3.11.2-macos11.pkg
3.10@https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
3.11@https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg
3.10@https://www.python.org/ftp/python/3.10.11/python-3.10.11-macos11.pkg
3.9@https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg
)