[mlir] Refactor finding python

This drops the use of deprecated CMake modules to find python.

Differential Revision: https://reviews.llvm.org/D91197
This commit is contained in:
Marius Brehler 2020-11-10 18:14:37 +01:00
parent 21f831134c
commit 07f1047f41
2 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -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}"
)