[Mlir-commits] [mlir] d75ac58 - [mlir] Add option to control python search priming

Stella Laurenzo llvmlistbot at llvm.org
Tue Mar 1 14:53:32 PST 2022


Author: rkayaith
Date: 2022-03-01T14:52:56-08:00
New Revision: d75ac5811705941eb254995acb90ac88fda895ad

URL: https://github.com/llvm/llvm-project/commit/d75ac5811705941eb254995acb90ac88fda895ad
DIFF: https://github.com/llvm/llvm-project/commit/d75ac5811705941eb254995acb90ac88fda895ad.diff

LOG: [mlir] Add option to control python search priming

This adds an option to configure the CMake python search priming
behaviour that was introduced in D118148. In some environments the
priming would cause the "real" search to fail. The default behaviour is
unchanged, i.e. the search will be primed.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D120765

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/cmake/modules/MLIRDetectPythonEnv.cmake

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index e049702ce4b13..1c1a281bf4fe5 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -130,6 +130,10 @@ set(MLIR_BUILD_MLIR_C_DYLIB 0 CACHE BOOL "Builds libMLIR-C shared library.")
 
 set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
        "Enables building of Python bindings.")
+set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL
+       "Prime the python detection by searching for a full 'Development' \
+       component first (temporary while diagnosing environment specific Python \
+       detection issues)")
 if(MLIR_ENABLE_BINDINGS_PYTHON)
   include(MLIRDetectPythonEnv)
   mlir_configure_python_dev_packages()

diff  --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
index 87039fd4b2e93..cb1fea1b55486 100644
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -23,11 +23,14 @@ macro(mlir_configure_python_dev_packages)
     )
     set(_python_development_component Development)
   else()
-    # Prime the search for python to see if there is a full
-    # development package. This seems to work around cmake bugs
-    # searching only for Development.Module in some environments.
-    find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
-      COMPONENTS Development)
+    if(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH)
+      # Prime the search for python to see if there is a full development
+      # package. This seems to work around cmake bugs searching only for
+      # Development.Module in some environments. However, in other environments
+      # it may interfere with the subsequent search for Development.Module.
+      find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+        COMPONENTS Development)
+    endif()
     set(_python_development_component Development.Module)
   endif()
   find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}


        


More information about the Mlir-commits mailing list