From 55cfcf11d66755521b3ac617b3832f78c5a45be2 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 27 Feb 2024 17:49:02 -0600 Subject: [PATCH] Added __version__ attr to Python Library Signed-off-by: Maisam Arif Change-Id: Ibbd90eaa60cc8b9dd0387d7fac8aef06a3a43375 --- py-interface/CMakeLists.txt | 3 +++ py-interface/__init__.py | 3 +++ py-interface/_version.py.in | 1 + 3 files changed, 7 insertions(+) create mode 100644 py-interface/_version.py.in diff --git a/py-interface/CMakeLists.txt b/py-interface/CMakeLists.txt index d55e9b6fca..f584ef7c1a 100644 --- a/py-interface/CMakeLists.txt +++ b/py-interface/CMakeLists.txt @@ -69,6 +69,7 @@ endif() # populate version string configure_file(pyproject.toml.in ${PY_BUILD_DIR}/pyproject.toml @ONLY) configure_file(setup.cfg.in ${PY_BUILD_DIR}/setup.cfg @ONLY) +configure_file(_version.py.in ${PY_PACKAGE_DIR}/_version.py @ONLY) add_custom_target( python_wrapper @@ -102,6 +103,7 @@ add_custom_target( python_package ALL DEPENDS ${PY_BUILD_DIR}/pyproject.toml ${PY_BUILD_DIR}/setup.cfg + ${PY_PACKAGE_DIR}/_version.py ${PY_PACKAGE_DIR}/__init__.py ${PY_PACKAGE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/amdsmi_interface.py @@ -114,6 +116,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/pyproject.toml ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/setup.cfg + ${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE_DIR}/_version.py DESTINATION ${PY_WRAPPER_INSTALL_DIR} COMPONENT dev) diff --git a/py-interface/__init__.py b/py-interface/__init__.py index da749f43f2..56304494fa 100644 --- a/py-interface/__init__.py +++ b/py-interface/__init__.py @@ -19,6 +19,9 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +# Library Version is the tool/amdsmi_interface version +from ._version import __version__ + # Library Initialization from .amdsmi_interface import amdsmi_init from .amdsmi_interface import amdsmi_shut_down diff --git a/py-interface/_version.py.in b/py-interface/_version.py.in new file mode 100644 index 0000000000..9ad803c8e4 --- /dev/null +++ b/py-interface/_version.py.in @@ -0,0 +1 @@ +__version__ = "@amd_smi_libraries_VERSION_STRING@" \ No newline at end of file