diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -130,6 +130,10 @@ 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 --- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake +++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake @@ -23,11 +23,14 @@ ) 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}