[ROCProfiler-SDK] Remove Python library dependency from Python bindings (#1451)
This commit is contained in:
@@ -28,15 +28,26 @@ macro(rocprofiler_reset_python3_cache)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# use Development.Module for manylinux compatibility
|
||||
set(ROCPROFILER_BUILD_Find_Python3_COMPONENTS
|
||||
"Interpreter;Development.Module"
|
||||
CACHE STRING "Components to find for Python3")
|
||||
|
||||
if(ROCPROFILER_MEMCHECK)
|
||||
# override with local variable for sanitizers. Sanitizers need Development (full) to
|
||||
# get Python3_LIBRARIES for linking
|
||||
set(ROCPROFILER_BUILD_Find_Python3_COMPONENTS "Interpreter" "Development")
|
||||
endif()
|
||||
|
||||
macro(rocprofiler_find_python3 _VERSION)
|
||||
rocprofiler_reset_python3_cache()
|
||||
|
||||
if("${_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
|
||||
find_package(Python3 ${_VERSION} EXACT ${ARGN} REQUIRED MODULE
|
||||
COMPONENTS Interpreter Development)
|
||||
COMPONENTS ${ROCPROFILER_BUILD_Find_Python3_COMPONENTS})
|
||||
elseif("${_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)$")
|
||||
find_package(Python3 ${_VERSION}.0...${_VERSION}.999 ${ARGN} REQUIRED MODULE
|
||||
COMPONENTS Interpreter Development)
|
||||
COMPONENTS ${ROCPROFILER_BUILD_Find_Python3_COMPONENTS})
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
@@ -56,7 +67,8 @@ function(get_default_python_versions _VAR)
|
||||
set(_PYTHON_FOUND_VERSIONS)
|
||||
|
||||
foreach(_VER IN LISTS ROCPROFILER_PYTHON_VERSION_CANDIDATES)
|
||||
find_package(Python3 ${_VER} EXACT QUIET COMPONENTS Interpreter Development)
|
||||
find_package(Python3 ${_VER} EXACT QUIET
|
||||
COMPONENTS ${ROCPROFILER_BUILD_Find_Python3_COMPONENTS})
|
||||
if(Python3_FOUND)
|
||||
list(APPEND _PYTHON_FOUND_VERSIONS
|
||||
"${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
|
||||
@@ -65,7 +77,7 @@ function(get_default_python_versions _VAR)
|
||||
|
||||
# If none found, do one last check for 3.6 (no EXACT)
|
||||
if(NOT _PYTHON_FOUND_VERSIONS)
|
||||
find_package(Python3 3.6 COMPONENTS Interpreter Development)
|
||||
find_package(Python3 3.6 COMPONENTS ${ROCPROFILER_BUILD_Find_Python3_COMPONENTS})
|
||||
if(Python3_FOUND)
|
||||
list(APPEND _PYTHON_FOUND_VERSIONS
|
||||
"${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
|
||||
@@ -112,7 +124,14 @@ function(rocprofiler_roctx_python_bindings _VERSION)
|
||||
target_link_libraries(
|
||||
rocprofiler-sdk-roctx-python-bindings-${_VERSION}
|
||||
PRIVATE rocprofiler-sdk-roctx::rocprofiler-sdk-roctx-shared-library
|
||||
rocprofiler-sdk::rocprofiler-sdk-pybind11 ${Python3_LIBRARIES})
|
||||
rocprofiler-sdk::rocprofiler-sdk-pybind11)
|
||||
|
||||
# if "Development" is specified instead of "Development.Module", we need to link to
|
||||
# python libraries
|
||||
if("Development" IN_LIST ROCPROFILER_BUILD_Find_Python3_COMPONENTS)
|
||||
target_link_libraries(rocprofiler-sdk-roctx-python-bindings-${_VERSION}
|
||||
PRIVATE ${Python3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
rocprofiler-sdk-roctx-python-bindings-${_VERSION}
|
||||
@@ -190,8 +209,14 @@ function(rocprofiler_rocpd_python_bindings _VERSION)
|
||||
rocprofiler-sdk::rocprofiler-sdk-gotcha
|
||||
rocprofiler-sdk::rocprofiler-sdk-dw
|
||||
rocprofiler-sdk::rocprofiler-sdk-static-library
|
||||
rocprofiler-sdk::rocprofiler-sdk-rocpd-library
|
||||
${Python3_LIBRARIES})
|
||||
rocprofiler-sdk::rocprofiler-sdk-rocpd-library)
|
||||
|
||||
# if "Development" is specified instead of "Development.Module", we need to link to
|
||||
# python libraries
|
||||
if("Development" IN_LIST ROCPROFILER_BUILD_Find_Python3_COMPONENTS)
|
||||
target_link_libraries(rocprofiler-sdk-rocpd-python-bindings-${_VERSION}
|
||||
PRIVATE ${Python3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
rocprofiler-sdk-rocpd-python-bindings-${_VERSION}
|
||||
|
||||
Reference in New Issue
Block a user