diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index c83b6f56b4cc..8c8d59280968 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -78,10 +78,9 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL "Links to specific python libraries, resolving all symbols.") if(MLIR_BINDINGS_PYTHON_ENABLED) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - message(STATUS "Found python include dirs: ${PYTHON_INCLUDE_DIRS}") - message(STATUS "Found python libraries: ${PYTHON_LIBRARIES}") + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}") + message(STATUS "Found python libraries: ${Python3_LIBRARIES}") find_package(pybind11 CONFIG REQUIRED) # TODO: pybind11 v2.6 switched from pybind11_INCLUDE_DIRS (plural) to # pybind11_INCLUDE_DIR (singular). A lot has changed in this area since this diff --git a/mlir/cmake/modules/AddMLIRPythonExtension.cmake b/mlir/cmake/modules/AddMLIRPythonExtension.cmake index 3cc01c7bd999..8a74675e2543 100644 --- a/mlir/cmake/modules/AddMLIRPythonExtension.cmake +++ b/mlir/cmake/modules/AddMLIRPythonExtension.cmake @@ -24,12 +24,12 @@ function(add_mlir_python_extension libname extname) # symbols, which is better for development. Note that not all python # configurations provide build-time libraries to link against, in which # case, we fall back to MODULE linking. - if(PYTHON_LIBRARIES STREQUAL "" OR NOT MLIR_PYTHON_BINDINGS_VERSION_LOCKED) + if(Python3_LIBRARIES STREQUAL "" OR NOT MLIR_PYTHON_BINDINGS_VERSION_LOCKED) set(PYEXT_LINK_MODE MODULE) set(PYEXT_LIBADD) else() set(PYEXT_LINK_MODE SHARED) - set(PYEXT_LIBADD ${PYTHON_LIBRARIES}) + set(PYEXT_LIBADD ${Python3_LIBRARIES}) endif() # The actual extension library produces a shared-object or DLL and has @@ -40,7 +40,7 @@ function(add_mlir_python_extension libname extname) ) target_include_directories(${libname} PRIVATE - "${PYTHON_INCLUDE_DIRS}" + "${Python3_INCLUDE_DIRS}" "${pybind11_INCLUDE_DIR}" )