|
2 | 2 |
|
3 | 3 | # Finds and configures python packages needed to build MLIR Python bindings.
|
4 | 4 | macro(mlir_configure_python_dev_packages)
|
5 |
| - if(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH) |
6 |
| - # Prime the search for python to see if there is a full development |
7 |
| - # package. This seems to work around cmake bugs searching only for |
8 |
| - # Development.Module in some environments. However, in other environments |
9 |
| - # it may interfere with the subsequent search for Development.Module. |
10 |
| - find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} |
11 |
| - COMPONENTS Interpreter Development) |
12 |
| - endif() |
| 5 | + if(NOT MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES) |
| 6 | + if(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH) |
| 7 | + # Prime the search for python to see if there is a full development |
| 8 | + # package. This seems to work around cmake bugs searching only for |
| 9 | + # Development.Module in some environments. However, in other environments |
| 10 | + # it may interfere with the subsequent search for Development.Module. |
| 11 | + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} |
| 12 | + COMPONENTS Interpreter Development) |
| 13 | + endif() |
13 | 14 |
|
14 |
| - # After CMake 3.18, we are able to limit the scope of the search to just |
15 |
| - # Development.Module. Searching for Development will fail in situations where |
16 |
| - # the Python libraries are not available. When possible, limit to just |
17 |
| - # Development.Module. |
18 |
| - # See https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode |
19 |
| - set(_python_development_component Development.Module) |
| 15 | + # After CMake 3.18, we are able to limit the scope of the search to just |
| 16 | + # Development.Module. Searching for Development will fail in situations where |
| 17 | + # the Python libraries are not available. When possible, limit to just |
| 18 | + # Development.Module. |
| 19 | + # See https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode |
| 20 | + set(_python_development_component Development.Module) |
20 | 21 |
|
21 |
| - find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} |
22 |
| - COMPONENTS Interpreter ${_python_development_component} REQUIRED) |
23 |
| - unset(_python_development_component) |
24 |
| - message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}") |
25 |
| - message(STATUS "Found python libraries: ${Python3_LIBRARIES}") |
26 |
| - message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}") |
27 |
| - mlir_detect_pybind11_install() |
28 |
| - find_package(pybind11 2.10 CONFIG REQUIRED) |
29 |
| - message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}") |
30 |
| - message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', " |
31 |
| - "suffix = '${PYTHON_MODULE_SUFFIX}', " |
32 |
| - "extension = '${PYTHON_MODULE_EXTENSION}") |
| 22 | + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} |
| 23 | + COMPONENTS Interpreter ${_python_development_component} REQUIRED) |
| 24 | + unset(_python_development_component) |
| 25 | + message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}") |
| 26 | + message(STATUS "Found python libraries: ${Python3_LIBRARIES}") |
| 27 | + message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}") |
| 28 | + mlir_detect_pybind11_install() |
| 29 | + find_package(pybind11 2.10 CONFIG REQUIRED) |
| 30 | + message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}") |
| 31 | + message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', " |
| 32 | + "suffix = '${PYTHON_MODULE_SUFFIX}', " |
| 33 | + "extension = '${PYTHON_MODULE_EXTENSION}") |
| 34 | + endif() |
33 | 35 | endmacro()
|
34 | 36 |
|
35 | 37 | # Detects a pybind11 package installed in the current python environment
|
|
0 commit comments