CLI: Make compatible with python3.6

Wrapper generation is still only compatible with python3.7 and above

Change-Id: I33cdc3925cd3fab80c9ce5f4540e1a981a5cc1f0
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>


[ROCm/amdsmi commit: adceb8033d]
Этот коммит содержится в:
Galantsev, Dmitrii
2023-03-21 16:57:55 -05:00
родитель a94331f293
Коммит 9aa803cfc0
5 изменённых файлов: 15 добавлений и 31 удалений
+2 -2
Просмотреть файл
@@ -21,7 +21,7 @@ In order to build the AMD SMI library, the following components are required. No
In order to build the AMD SMI python package, the following components are required:
* clang (14.0 or above)
* python (3.7 or above)
* python (3.6 or above)
* virtualenv - `pip3 install virtualenv`
In order to build the latest documentation, the following are required:
@@ -169,7 +169,7 @@ make python_wrapper # or simply 'make'
After this command, the file in `py-interface/amdsmi_wrapper.py` will be automatically updated on each compile.
Note: To be able to re-generate python wrapper you need several tools installed on your system: clang-14, clang-format, libclang-dev
Note: To be able to re-generate python wrapper you need several tools installed on your system: clang-14, clang-format, libclang-dev, and ***python3.7 or newer***.
Note: python_wrapper is NOT automatically re-generated. You must run `cmake` with `-DBUILD_WRAPPER=on` argument.
+1 -12
Просмотреть файл
@@ -9,18 +9,7 @@ set(PY_CLI_INSTALL_DIR
"${CMAKE_INSTALL_LIBEXECDIR}" CACHE STRING
"CLI tool installation directory")
# if Python3 is found but the version is below 3.7 - Python3_FOUND is set to FALSE
find_package(Python3 3.7 COMPONENTS Interpreter Development)
# WARN: This is a HACK to pass compile on AMD rhel8 and centos7 CI systems!
# Those still use python3.6 which is too old for this project!
# TODO: Promote to an error when python3.7 or above is installed on CI
if(NOT Python3_FOUND)
message(AUTHOR_WARNING "Python3 DOESN'T EXIST OR VERSION IS TOO OLD!: ${Python3_VERSION}")
message(AUTHOR_WARNING "The CLI tool will not be created and the project will not be packaged!")
# WARN: EXIT CURRENT CMAKE FILE
return()
endif()
find_package(Python3 3.6 COMPONENTS Interpreter Development REQUIRED)
# hard-linking instead of copying avoids unnecessarry regeneration of packaged files
add_custom_command(
+11 -2
Просмотреть файл
@@ -372,9 +372,18 @@ class AMDSMILogger():
if self.destination == 'stdout':
if watch_output:
return
# print_output may need another value: flush_output vs watch_output
print(human_readable)
return
# printing as unicode may fail if locale is not set properly
# see: https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20
# export PYTHONIOENCODING=utf8
try:
# print as unicode
print(human_readable)
except UnicodeEncodeError:
# print as ascii, ignore incompatible characters
print(human_readable.encode('ascii', 'ignore').decode('ascii'))
else:
if watch_output:
return
-2
Просмотреть файл
@@ -56,9 +56,7 @@ class AMDSMIParser(argparse.ArgumentParser):
subparsers = self.add_subparsers(
title="AMD-SMI Commands",
parser_class=argparse.ArgumentParser,
required=True,
help="Descriptions:",
# dest='cmd',
metavar="")
# Add all subparsers
+1 -13
Просмотреть файл
@@ -11,19 +11,6 @@ set(PY_BUILD_DIR "python_package")
set(PY_PACKAGE_DIR "${PY_BUILD_DIR}/amdsmi")
set(PY_WRAPPER_INSTALL_DIR "${SHARE_INSTALL_PREFIX}" CACHE STRING "Wrapper installation directory")
# if Python3 is found but the version is below 3.7 - Python3_FOUND is set to FALSE
find_package(Python3 3.7 COMPONENTS Interpreter Development)
# WARN: This is a HACK to pass compile on AMD rhel8 and centos7 CI systems!
# Those still use python3.6 which is too old for this project!
# TODO: Promote to an error when python3.7 or above is installed on CI
if(NOT Python3_FOUND)
message(AUTHOR_WARNING "Python3 DOESN'T EXIST OR VERSION IS TOO OLD!: ${Python3_VERSION}")
message(AUTHOR_WARNING "The wrapper will not be created and the project will not be packaged!")
# WARN: EXIT CURRENT CMAKE FILE
return()
endif()
# TODO: Figure out how python-clang and clang are related
# Currently only a very specific combination works
@@ -59,6 +46,7 @@ if(NOT GOOD_CLANG_FOUND)
COMMAND mkdir -p ${PY_PACKAGE_DIR}
COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
else()
find_package(Python3 3.7 COMPONENTS Interpreter Development REQUIRED)
add_custom_target(
python_pre_reqs
COMMAND ${Python3_EXECUTABLE} -m pip install clang==${clang_ver} ctypeslib2==${ctypeslib_ver})