Skip to content

Commit

Permalink
Merge amd-dev into amd-master 20240318
Browse files Browse the repository at this point in the history
Signed-off-by: guanyu12 <[email protected]>
Change-Id: I7949bbc5f3c1cd1118fabc9e85e1371b1436d0b0
  • Loading branch information
guanyu12 committed Mar 18, 2024
2 parents fc53ab5 + eef4169 commit ad7ee51
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include(GNUInstallDirs)

option(BUILD_TESTS "Build test suite" OFF)
# TODO: Enable once virtualenv is installed on CI machines
option(BUILD_WRAPPER "Rebuild AMDSMI-wrapper" OFF)
option(BUILD_CLI "Build AMDSMI-CLI and install" ON)
option(ENABLE_LDCONFIG "Set library links and caches using ldconfig." ON)
option(ENABLE_ASAN_PACKAGING "" OFF)
option(ENABLE_ESMI_LIB "" ON)

include(CMakeDependentOption)
# these options don't work without BUILD_SHARED_LIBS
cmake_dependent_option(BUILD_WRAPPER "Rebuild AMDSMI-wrapper" OFF "BUILD_SHARED_LIBS" OFF)
cmake_dependent_option(BUILD_CLI "Build AMDSMI-CLI and install" ON "BUILD_SHARED_LIBS" OFF)
cmake_dependent_option(ENABLE_LDCONFIG "Set library links and caches using ldconfig." ON "BUILD_SHARED_LIBS" OFF)

# Set share path here because project name != amd_smi
set(SHARE_INSTALL_PREFIX "share/${AMD_SMI}" CACHE STRING "Tests and Example install directory")

Expand Down Expand Up @@ -185,10 +187,12 @@ if(BUILD_TESTS)
add_subdirectory("tests/amd_smi_test")
endif()

add_subdirectory("py-interface")

if(BUILD_CLI)
add_subdirectory("amdsmi_cli")
# python interface and CLI depend on shared libraries
if(BUILD_SHARED_LIBS)
add_subdirectory("py-interface")
if(BUILD_CLI)
add_subdirectory("amdsmi_cli")
endif()
endif()

include(CMakePackageConfigHelpers)
Expand Down
20 changes: 16 additions & 4 deletions DEBIAN/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,30 @@ do_install_amdsmi_python_lib() {
echo "Removed old AMD-SMI python library (amdsmi)..."
fi

# static builds don't include python lib
if [ "@BUILD_SHARED_LIBS@" != "ON" ]; then
return
fi

# upgrade pip if it's an ancient version
# otherwise the amdsmi install will fail
local pip_version
pip_version=$(python3 -m pip --version | grep -Eo '^[^\ ]+ ([0-9]+)' | grep -Eo '[0-9]+$')
if [[ "$pip_version" -lt 19 ]]; then
echo "Detected ancient pip version ($pip_version)... Upgrading..."
python3 -m pip install --upgrade pip --quiet --disable-pip-version-check
echo "Detected ancient pip version ($pip_version)... Upgrading..."
python3 -m pip install --upgrade pip --quiet --disable-pip-version-check
fi
unset pip_version

# install PyYAML dependency
python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed
# Check PyYAML dependency
local pyyaml_version
pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]')
if [[ "$pyyaml_version" -lt 5 ]]; then
echo "Detected ancient pyyaml version ($pyyaml_version)... Upgrading..."
python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed
fi
unset pyyaml_version

# install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check
Expand Down
20 changes: 16 additions & 4 deletions RPM/post.in
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,30 @@ do_install_amdsmi_python_lib() {
echo "Removed old AMD-SMI python library (amdsmi)..."
fi

# static builds don't include python lib
if [ "@BUILD_SHARED_LIBS@" != "ON" ]; then
return
fi

# upgrade pip if it's an ancient version
# otherwise the amdsmi install will fail
local pip_version
pip_version=$(python3 -m pip --version | grep -Eo '^[^\ ]+ ([0-9]+)' | grep -Eo '[0-9]+$')
if [[ "$pip_version" -lt 19 ]]; then
echo "Detected ancient pip version ($pip_version)... Upgrading..."
python3 -m pip install --upgrade pip --quiet --disable-pip-version-check
echo "Detected ancient pip version ($pip_version)... Upgrading..."
python3 -m pip install --upgrade pip --quiet --disable-pip-version-check
fi
unset pip_version

# install PyYAML dependency
python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed
# Check PyYAML dependency
local pyyaml_version
pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]')
if [[ "$pyyaml_version" -lt 5 ]]; then
echo "Detected ancient pyyaml version ($pyyaml_version)... Upgrading..."
python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed
fi
unset pyyaml_version

# install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check
Expand Down

0 comments on commit ad7ee51

Please sign in to comment.