From c0d8a2e0a791693ed5dfc868ce6b9410135da39b 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 | 3 +++ setup.py | 2 ++ 4 files changed, 7 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 2e1648679c57..eed5e041e0c9 100644 --- a/build_tools/python_deploy/build_windows_ci.sh +++ b/build_tools/python_deploy/build_windows_ci.sh @@ -11,6 +11,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 61c60a646a5c..0a49c1a9face 100644 --- a/docs/development.md +++ b/docs/development.md @@ -61,6 +61,7 @@ cmake -GNinja -Bbuild \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_EXTERNAL_PROJECTS="torch-mlir" \ -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \ @@ -93,6 +94,7 @@ If you're running into issues with the above build command, consider using the f cmake -GNinja -Bbuild \ -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" \ @@ -125,6 +127,7 @@ If you have built llvm-project separately in the directory `$LLVM_INSTALL_DIR`, cmake -GNinja -Bbuild \ -DCMAKE_BUILD_TYPE=Release \ -DPython3_FIND_VIRTUALENV=ONLY \ + -DPython_FIND_VIRTUALENV=ONLY \ -DMLIR_DIR="$LLVM_INSTALL_DIR/lib/cmake/mlir/" \ -DLLVM_DIR="$LLVM_INSTALL_DIR/lib/cmake/llvm/" \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ 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",