[Mlir-commits] [mlir] 7aebdfc - [mlir] Limit Python dependency to Development.Module when possible.

Mike Urbach llvmlistbot at llvm.org
Thu Oct 7 22:05:48 PDT 2021


Author: Mike Urbach
Date: 2021-10-07T23:05:43-06:00
New Revision: 7aebdfc4fcc4a2667f5d5c30ffbdc146f9b014d2

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

LOG: [mlir] Limit Python dependency to Development.Module when possible.

After CMake 3.18, we are able to limit the scope of the
find_package(Python3 ...) search to just Development.Module. Searching
for Development will fail in manylinux builds, and isn't necessary
since we are not embedding the Python interpreter. For more information, see:
https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode

Reviewed By: stellaraccident

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

Added: 
    

Modified: 
    mlir/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index b7ac3bdc543f..2f0e8b214bff 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -112,8 +112,17 @@ set(MLIR_BINDINGS_PYTHON_LOCK_VERSION 1 CACHE BOOL
 
 if(MLIR_ENABLE_BINDINGS_PYTHON)
   include(MLIRDetectPythonEnv)
+  # After CMake 3.18, we are able to limit the scope of the search to just
+  # Development.Module. Searching for Development will fail in manylinux builds,
+  # and isn't necessary since we are not embedding the Python interpreter.
+  # See https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode
+  if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
+    set(_python_development_component Development)
+  else()
+    set(_python_development_component Development.Module)
+  endif()
   find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
-    COMPONENTS Interpreter Development NumPy REQUIRED)
+    COMPONENTS Interpreter ${_python_development_component} NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")


        


More information about the Mlir-commits mailing list