From 25c8ff6c2af92e363723ab3a17923399c516d0fa Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 12 Mar 2024 15:35:31 -0500 Subject: [PATCH 1/2] SWDEV-449314 - Added pyyaml check before installing via pip Signed-off-by: Maisam Arif Change-Id: Ie6d0d664e74b47c1efce6e6fac19ee4a1bf0d5eb --- DEBIAN/postinst.in | 15 +++++++++++---- RPM/post.in | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/DEBIAN/postinst.in b/DEBIAN/postinst.in index d991cf6b2a..f0d58d529b 100755 --- a/DEBIAN/postinst.in +++ b/DEBIAN/postinst.in @@ -143,13 +143,20 @@ do_install_amdsmi_python_lib() { 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 diff --git a/RPM/post.in b/RPM/post.in index a58a5f4e8f..5b5fc9595d 100755 --- a/RPM/post.in +++ b/RPM/post.in @@ -142,13 +142,20 @@ do_install_amdsmi_python_lib() { 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 From eef4169a0f7f0d1f65cb593612e89f8f67c65287 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 14 Mar 2024 03:43:52 -0500 Subject: [PATCH 2/2] SWDEV-449212 - Fix static build Disable Python interface and CLI tool for static builds (when -DBUILD_SHARED_LIBS=OFF is passed to cmake) Change-Id: I32bbd94d70628a50029a748f7493b55c91d45e02 Signed-off-by: Galantsev, Dmitrii --- CMakeLists.txt | 20 ++++++++++++-------- DEBIAN/postinst.in | 5 +++++ RPM/post.in | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e290230e22..d59fe2f43f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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) diff --git a/DEBIAN/postinst.in b/DEBIAN/postinst.in index f0d58d529b..3d0535d8a7 100755 --- a/DEBIAN/postinst.in +++ b/DEBIAN/postinst.in @@ -138,6 +138,11 @@ 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 diff --git a/RPM/post.in b/RPM/post.in index 5b5fc9595d..653b365f8f 100755 --- a/RPM/post.in +++ b/RPM/post.in @@ -137,6 +137,11 @@ 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