Skip to content

Commit 682db01

Browse files
authored
build: RHEL8 Python Backend (#385)
* PYBE RHEL
1 parent a2564ea commit 682db01

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ FetchContent_Declare(
9292
GIT_TAG "aa304c9c7d725ffb9d10af08a3b34cb372307020"
9393
GIT_SHALLOW ON
9494
)
95+
96+
# RHEL base container has multiple version of Python installed. By default
97+
# it seems like pybind will pickup v3.6, so we specifically assign it to
98+
# search for 3.12 here.
99+
set(RHEL_BUILD OFF)
100+
if(LINUX)
101+
file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE")
102+
if(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
103+
set(RHEL_BUILD ON)
104+
set(PYBIND11_PYTHON_VERSION 3.12)
105+
endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
106+
endif(LINUX)
95107
FetchContent_MakeAvailable(pybind11)
96108

97109
#
@@ -268,6 +280,23 @@ target_compile_options(
268280
)
269281
target_compile_definitions(triton-python-backend-stub PRIVATE TRITON_PB_STUB)
270282

283+
# RHEL assets are not released in a container environment nor do the current
284+
# Python lib versions in the manylinux base container match those currently
285+
# available for RHEL8 package managers. Therefore, we package the correct
286+
# python libs in the backend folder and adjust the stub executable to look
287+
# in its own folder at runtime.
288+
if(RHEL_BUILD)
289+
set_target_properties(
290+
triton-python-backend-stub
291+
PROPERTIES
292+
SKIP_BUILD_RPATH TRUE
293+
BUILD_WITH_INSTALL_RPATH TRUE
294+
INSTALL_RPATH_USE_LINK_PATH FALSE
295+
INSTALL_RPATH "$\{ORIGIN\}"
296+
)
297+
endif(RHEL_BUILD)
298+
299+
271300
# For WIN32 do not link Threads and DL_LIBS
272301
if(WIN32)
273302
target_link_libraries(

0 commit comments

Comments
 (0)