Skip to content

Commit 07f1047

Browse files
committed
[mlir] Refactor finding python
This drops the use of deprecated CMake modules to find python. Differential Revision: https://reviews.llvm.org/D91197
1 parent 21f8311 commit 07f1047

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

mlir/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
7878
"Links to specific python libraries, resolving all symbols.")
7979

8080
if(MLIR_BINDINGS_PYTHON_ENABLED)
81-
find_package(PythonInterp REQUIRED)
82-
find_package(PythonLibs REQUIRED)
83-
message(STATUS "Found python include dirs: ${PYTHON_INCLUDE_DIRS}")
84-
message(STATUS "Found python libraries: ${PYTHON_LIBRARIES}")
81+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
82+
message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
83+
message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
8584
find_package(pybind11 CONFIG REQUIRED)
8685
# TODO: pybind11 v2.6 switched from pybind11_INCLUDE_DIRS (plural) to
8786
# pybind11_INCLUDE_DIR (singular). A lot has changed in this area since this

mlir/cmake/modules/AddMLIRPythonExtension.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ function(add_mlir_python_extension libname extname)
2424
# symbols, which is better for development. Note that not all python
2525
# configurations provide build-time libraries to link against, in which
2626
# case, we fall back to MODULE linking.
27-
if(PYTHON_LIBRARIES STREQUAL "" OR NOT MLIR_PYTHON_BINDINGS_VERSION_LOCKED)
27+
if(Python3_LIBRARIES STREQUAL "" OR NOT MLIR_PYTHON_BINDINGS_VERSION_LOCKED)
2828
set(PYEXT_LINK_MODE MODULE)
2929
set(PYEXT_LIBADD)
3030
else()
3131
set(PYEXT_LINK_MODE SHARED)
32-
set(PYEXT_LIBADD ${PYTHON_LIBRARIES})
32+
set(PYEXT_LIBADD ${Python3_LIBRARIES})
3333
endif()
3434

3535
# The actual extension library produces a shared-object or DLL and has
@@ -40,7 +40,7 @@ function(add_mlir_python_extension libname extname)
4040
)
4141

4242
target_include_directories(${libname} PRIVATE
43-
"${PYTHON_INCLUDE_DIRS}"
43+
"${Python3_INCLUDE_DIRS}"
4444
"${pybind11_INCLUDE_DIR}"
4545
)
4646

0 commit comments

Comments
 (0)