Skip to content

Commit

Permalink
Failsafe find_package(PythonLibs REQUIRED)
Browse files Browse the repository at this point in the history
  • Loading branch information
chudur-budur committed Aug 6, 2023
1 parent 844bac5 commit 0750d76
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions numba_dpex/core/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,33 @@ message(STATUS "CMAKE_MODULE_PATH=" "${CMAKE_MODULE_PATH}")

# Add packages
find_package(PythonLibs REQUIRED)

if(NOT PythonLibs_FOUND)
# Manually get PYTHON_INCLUDE_DIRS
execute_process(
COMMAND python -c "import sysconfig; print(sysconfig.get_path('include'))"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Couldn't find PYTHON_INCLUDE_DIRS")
endif()

# Manually PYTHON_LIBRARIES
execute_process(
COMMAND python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
OUTPUT_VARIABLE PYTHON_LIBRARIES
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Couldn't find PYTHON_LIBRARIES")
endif()
endif()

find_package(PythonExtensions REQUIRED)
find_package(NumPy REQUIRED)
find_package(Dpctl REQUIRED)
Expand Down

0 comments on commit 0750d76

Please sign in to comment.