From 4e4a3fdb432803656a9bc200abfe844020eae268 Mon Sep 17 00:00:00 2001 From: Dmitry Babokin Date: Thu, 6 Feb 2025 16:32:38 -0800 Subject: [PATCH] Define Python_FIND_VIRTUALENV in addition to Python3_FIND_VIRTUALENV MLIR searches for both Python3 and Python. If both variables are not defined equally and there multiple python version on the system, CMake may behave really weirdly. More details here: https://github.com/llvm/llvm-project/issues/126162 --- build_tools/e2eshark_build.sh | 1 + build_tools/python_deploy/build_windows_ci.sh | 1 + docs/development.md | 2 ++ setup.py | 2 ++ 4 files changed, 6 insertions(+) diff --git a/build_tools/e2eshark_build.sh b/build_tools/e2eshark_build.sh index 08da0caad051..39012d32c0e2 100644 --- a/build_tools/e2eshark_build.sh +++ b/build_tools/e2eshark_build.sh @@ -21,6 +21,7 @@ cmake -S "$repo_root/externals/llvm-project/llvm" -B "$build_dir" \ -GNinja \ -DCMAKE_BUILD_TYPE=Release \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_EXTERNAL_PROJECTS="torch-mlir" \ -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \ diff --git a/build_tools/python_deploy/build_windows_ci.sh b/build_tools/python_deploy/build_windows_ci.sh index c678eaf79a04..f0fe9cdb8dd5 100644 --- a/build_tools/python_deploy/build_windows_ci.sh +++ b/build_tools/python_deploy/build_windows_ci.sh @@ -33,6 +33,7 @@ cmake -GNinja -Bbuild \ -DLLVM_TARGETS_TO_BUILD=host \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DLLVM_EXTERNAL_PROJECTS="torch-mlir" \ -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \ -DPython3_EXECUTABLE="$(which python)" \ diff --git a/docs/development.md b/docs/development.md index bb81ad215372..f1e72966f84d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -105,6 +105,7 @@ sudo apt install clang ccache lld -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DLLVM_TARGETS_TO_BUILD=host \ `# For building LLVM "in-tree"` \ @@ -123,6 +124,7 @@ sudo apt install clang ccache lld -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DLLVM_TARGETS_TO_BUILD=host \ `# For building LLVM "out-of-tree"` \ diff --git a/setup.py b/setup.py index b04a15004e76..afb67496136f 100644 --- a/setup.py +++ b/setup.py @@ -113,6 +113,8 @@ def cmake_build(self, cmake_build_dir): f"-DCMAKE_BUILD_TYPE={CMAKE_BUILD_TYPE}", f"-DPython3_EXECUTABLE={sys.executable}", f"-DPython3_FIND_VIRTUALENV=ONLY", + f"-DPython_EXECUTABLE={sys.executable}", + f"-DPython_FIND_VIRTUALENV=ONLY", f"-DMLIR_ENABLE_BINDINGS_PYTHON=ON", f"-DLLVM_TARGETS_TO_BUILD=host", f"-DLLVM_ENABLE_ZSTD=OFF",