[SWDEV-482058 / SWDEV-482971] Added setup.py install
Signed-off-by: Justin Williams <Justin.Williams@amd.com> Change-Id: Ibad07d34dfb455043ce307fe036289f1d5c20a9a
This commit is contained in:
کامیت شده توسط
Maisam Arif
والد
25bcf6af2a
کامیت
2e5b164c43
+29
-6
@@ -134,10 +134,10 @@ do_install_amdsmi_python_lib() {
|
||||
export PIP_BREAK_SYSTEM_PACKAGES=1
|
||||
|
||||
# Remove old python library
|
||||
local pip_list_output
|
||||
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
||||
local amdsmi_pip_list_output
|
||||
amdsmi_pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
||||
# check pip list output for amdsmi
|
||||
if [[ $pip_list_output == *"amdsmi"* ]]; then
|
||||
if [[ $amdsmi_pip_list_output == *"amdsmi"* ]]; then
|
||||
echo "Detected old AMD-SMI python library (amdsmi)..."
|
||||
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
|
||||
echo "Removed old AMD-SMI python library (amdsmi)..."
|
||||
@@ -148,9 +148,32 @@ do_install_amdsmi_python_lib() {
|
||||
return
|
||||
fi
|
||||
|
||||
# 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 --no-build-isolation --no-index
|
||||
check_and_install_amdsmi() {
|
||||
local setuptools_version
|
||||
setuptools_version=$(python3 -c 'import setuptools; print(setuptools.__version__)')
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not determine setuptools version. "\
|
||||
"AMD-SMI python library will not be installed."
|
||||
return
|
||||
fi
|
||||
|
||||
local amdsmi_python_lib_path="/opt/rocm/share/amd_smi"
|
||||
local amdsmi_setup_py_path="/opt/rocm/share/amd_smi/setup.py"
|
||||
|
||||
# Decide installation method based on setuptools version
|
||||
if [[ "$(printf '%s\n' "$setuptools_version" "28.5" | sort -V | head -n1)" == "$setuptools_version" ]]; then
|
||||
echo "[WARNING] Setuptools version is less than 28.5. AMD-SMI will not be installed."
|
||||
elif [[ "$(printf '%s\n' "$setuptools_version" "41.0.1" | sort -V | head -n1)" != "41.0.1" ]]; then
|
||||
echo "Using setup.py for installation due to setuptools version $setuptools_version"
|
||||
python3 "$amdsmi_setup_py_path" install
|
||||
else
|
||||
echo "Using pyproject.toml for installation due to setuptools version $setuptools_version"
|
||||
python3 -m pip install "$amdsmi_python_lib_path" --quiet --disable-pip-version-check --no-build-isolation --no-index
|
||||
fi
|
||||
}
|
||||
|
||||
# Call the function
|
||||
check_and_install_amdsmi
|
||||
|
||||
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_USER_ACTION"
|
||||
export PIP_BREAK_SYSTEM_PACKAGES="$PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES"
|
||||
|
||||
+30
-6
@@ -134,10 +134,10 @@ do_install_amdsmi_python_lib() {
|
||||
|
||||
|
||||
# Remove old python library
|
||||
local pip_list_output
|
||||
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
||||
local amdsmi_pip_list_output
|
||||
amdsmi_pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
||||
# check pip list output for amdsmi
|
||||
if [[ $pip_list_output == *"amdsmi"* ]]; then
|
||||
if [[ $amdsmi_pip_list_output == *"amdsmi"* ]]; then
|
||||
echo "Detected old AMD-SMI python library (amdsmi)..."
|
||||
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
|
||||
echo "Removed old AMD-SMI python library (amdsmi)..."
|
||||
@@ -148,9 +148,33 @@ do_install_amdsmi_python_lib() {
|
||||
return
|
||||
fi
|
||||
|
||||
# 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 --no-build-isolation --no-index
|
||||
check_and_install_amdsmi() {
|
||||
local setuptools_version
|
||||
setuptools_version=$(python3 -c 'import setuptools; print(setuptools.__version__)')
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not determine setuptools version. "\
|
||||
"AMD-SMI python library will not be installed."
|
||||
return
|
||||
fi
|
||||
|
||||
local amdsmi_python_lib_path="/opt/rocm/share/amd_smi"
|
||||
local amdsmi_setup_py_path="/opt/rocm/share/amd_smi/setup.py"
|
||||
|
||||
# Decide installation method based on setuptools version
|
||||
if [[ "$(printf '%s\n' "$setuptools_version" "28.5" | sort -V | head -n1)" == "$setuptools_version" ]]; then
|
||||
echo "[WARNING] Setuptools version is less than 28.5. AMD-SMI will not be installed."
|
||||
elif [[ "$(printf '%s\n' "$setuptools_version" "41.0.1" | sort -V | head -n1)" != "41.0.1" ]]; then
|
||||
echo "Using setup.py for installation due to setuptools version $setuptools_version"
|
||||
python3 "$amdsmi_setup_py_path" install
|
||||
else
|
||||
echo "Using pyproject.toml for installation due to setuptools version $setuptools_version"
|
||||
python3 -m pip install "$amdsmi_python_lib_path" --quiet --disable-pip-version-check --no-build-isolation --no-index
|
||||
fi
|
||||
}
|
||||
|
||||
# Call the function
|
||||
check_and_install_amdsmi
|
||||
|
||||
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_USER_ACTION"
|
||||
export PIP_BREAK_SYSTEM_PACKAGES="$PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES"
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ endif()
|
||||
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)
|
||||
configure_file(setup.py.in ${PY_BUILD_DIR}/setup.py @ONLY)
|
||||
|
||||
add_custom_target(
|
||||
python_wrapper
|
||||
@@ -103,6 +104,7 @@ add_custom_target(
|
||||
python_package ALL
|
||||
DEPENDS ${PY_BUILD_DIR}/pyproject.toml
|
||||
${PY_BUILD_DIR}/setup.cfg
|
||||
${PY_BUILD_DIR}/setup.py
|
||||
${PY_PACKAGE_DIR}/_version.py
|
||||
${PY_PACKAGE_DIR}/__init__.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_exception.py
|
||||
@@ -116,6 +118,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_BUILD_DIR}/setup.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE_DIR}/_version.py
|
||||
DESTINATION ${PY_WRAPPER_INSTALL_DIR}
|
||||
COMPONENT dev)
|
||||
|
||||
@@ -16,7 +16,7 @@ readme = {file = "amdsmi/README.md", content-type = "text/markdown"}
|
||||
description = "AMDSMI Python LIB - AMD GPU Monitoring Library"
|
||||
requires-python = ">=3.6"
|
||||
dependencies = [
|
||||
"PyYAML >= 3.12",
|
||||
"PyYAML >= 3.0",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
||||
@@ -18,7 +18,7 @@ include_package_data = True
|
||||
packages = find:
|
||||
python_requires = >=3.6
|
||||
install_requires=
|
||||
PyYAML >= 3.12
|
||||
PyYAML >= 3.0
|
||||
|
||||
[options.package_data]
|
||||
* = *.so
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from setuptools import setup, find_packages
|
||||
import os
|
||||
|
||||
setup(
|
||||
name="amdsmi",
|
||||
version="@amd_smi_libraries_VERSION_STRING@",
|
||||
author="AMD",
|
||||
author_email="amd-smi.support@amd.com",
|
||||
description="AMDSMI Python LIB - AMD GPU Monitoring Library",
|
||||
url="https://github.com/ROCm/amdsmi",
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
"PyYAML>=3.0",
|
||||
],
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
include_package_data=True,
|
||||
package_data={
|
||||
'': ['*.so'],
|
||||
},
|
||||
zip_safe=False,
|
||||
license='amdsmi/LICENSE',
|
||||
)
|
||||
مرجع در شماره جدید
Block a user