CMake: Replace .whl with libexec install
Generating .whl has proved to be difficult with AMD CI. Switch to directly installing python projects instead. Change-Id: I8a4c2fe22fc872865bba7da3a3386513efd5269a Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Этот коммит содержится в:
@@ -54,8 +54,8 @@ include(GNUInstallDirs)
|
||||
|
||||
option(BUILD_TESTS "Build test suite" OFF)
|
||||
# TODO: Enable once virtualenv is installed on CI machines
|
||||
option(BUILD_PACKAGE "Build python package" OFF)
|
||||
option(ENABLE_CLI "Enable AMDSMI-CLI install" OFF)
|
||||
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)
|
||||
|
||||
# Set share path here because project name != amd_smi
|
||||
@@ -131,11 +131,9 @@ if(BUILD_TESTS)
|
||||
add_subdirectory("tests/amd_smi_test")
|
||||
endif()
|
||||
|
||||
if(BUILD_PACKAGE)
|
||||
add_subdirectory("py-interface")
|
||||
endif()
|
||||
add_subdirectory("py-interface")
|
||||
|
||||
if(ENABLE_CLI)
|
||||
if(BUILD_CLI)
|
||||
add_subdirectory("amdsmi_cli")
|
||||
endif()
|
||||
|
||||
@@ -207,6 +205,8 @@ if(CPACK_RPM_PACKAGE_RELEASE)
|
||||
endif()
|
||||
set(CPACK_RPM_PACKAGE_PROVIDES "amd-smi")
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "python3")
|
||||
# don't terminate if bytecompile of python files fails
|
||||
set(CPACK_RPM_SPEC_MORE_DEFINE "%define _python_bytecompile_errors_terminate_build 0")
|
||||
|
||||
# Add rocm-core dependency if -DROCM_DEP_ROCMCORE=ON is passed
|
||||
if(ROCM_DEP_ROCMCORE)
|
||||
|
||||
+4
-19
@@ -163,30 +163,15 @@ The python wrapper (binding) is an auto-generated file `py-interface/amdsmi_wrap
|
||||
Wrapper should be re-generated on each C++ API change, by doing:
|
||||
|
||||
```bash
|
||||
make python_wrapper
|
||||
cmake .. -DBUILD_WRAPPER=on
|
||||
make python_wrapper # or simply 'make'
|
||||
```
|
||||
|
||||
After this command, the file in `py-interface/amdsmi_wrapper.py` will be automatically updated.
|
||||
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: python_wrapper is automatically generated with normal `make` and `make python_package` commands.
|
||||
|
||||
Warning: If clang version is older than clang-14 - the wrapper generation will fail with a warning.
|
||||
To mitigate this issue - we include a pre-generated version of the wrapper.
|
||||
|
||||
# Python package
|
||||
`amdsmi` package can be generated by running:
|
||||
|
||||
```bash
|
||||
make python_package
|
||||
```
|
||||
|
||||
It will be placed in following location: `build/py-interface/python_package/amdsmi-0.1-py3-none-any.whl`
|
||||
|
||||
The .whl package can be installed using `pip3 install amdsmi-0.1-py3-none-any.whl` command.
|
||||
|
||||
Warning: You must have python3.7 or above with virtualenv installed. Otherwise packaging will fail with a warning.
|
||||
Note: python_wrapper is NOT automatically re-generated. You must run `cmake` with `-DBUILD_WRAPPER=on` argument.
|
||||
|
||||
## DISCLAIMER
|
||||
|
||||
|
||||
@@ -4,86 +4,86 @@ message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
|
||||
|
||||
# Set CLI Build Directory
|
||||
set(CLI_BUILD_DIR "amdsmi_cli" CACHE STRING "")
|
||||
set(SHARE_WHL_LOCATION "${SHARE_INSTALL_PREFIX}/${AMD_SMI}/amdsmi-0.1-py3-none-any.whl")
|
||||
|
||||
# The CLI requires the python amdsmi wrapper whl file to exist
|
||||
add_custom_target(
|
||||
amdsmi_cli
|
||||
DEPENDS SHARE_WHL_LOCATION)
|
||||
set(PY_PACKAGE_DIR "amdsmi_cli")
|
||||
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)
|
||||
find_package(Python3 3.7 COMPONENTS Interpreter Development)
|
||||
|
||||
# WARN: This is a HACK to pass compile on AMD rhel8 CI systems!
|
||||
# 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()
|
||||
|
||||
add_custom_target(
|
||||
amdsmi_whl_install
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade --force-reinstall SHARE_WHL_LOCATION)
|
||||
|
||||
# symlinking instead of copying avoids unnecessarry regeneration of packaged files
|
||||
# hard-linking instead of copying avoids unnecessarry regeneration of packaged files
|
||||
add_custom_command(
|
||||
OUTPUT ${CLI_BUILD_DIR}/pyproject.toml
|
||||
${CLI_BUILD_DIR}/__init__.py
|
||||
${CLI_BUILD_DIR}/_version.py
|
||||
${CLI_BUILD_DIR}/amdsmi_cli.py
|
||||
${CLI_BUILD_DIR}/amdsmi_commands.py
|
||||
${CLI_BUILD_DIR}/amdsmi_helpers.py
|
||||
${CLI_BUILD_DIR}/amdsmi_logger.py
|
||||
${CLI_BUILD_DIR}/amdsmi_parser.py
|
||||
${CLI_BUILD_DIR}/BDF.py
|
||||
OUTPUT ${PY_PACKAGE_DIR}/__init__.py
|
||||
${PY_PACKAGE_DIR}/_version.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_cli.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_commands.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_helpers.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_init.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_logger.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_parser.py
|
||||
${PY_PACKAGE_DIR}/BDF.py
|
||||
DEPENDS amdsmi_cli
|
||||
amdsmi_whl_install
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/_version.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_commands.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_helpers.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_logger.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_parser.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/BDF.py ${CLI_BUILD_DIR}/)
|
||||
COMMAND mkdir -p ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/_version.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_commands.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_helpers.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_init.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_logger.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_parser.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/BDF.py ${PY_PACKAGE_DIR}/)
|
||||
|
||||
# The CLI requires the python amdsmi wrapper to be installed
|
||||
add_custom_target(
|
||||
amdsmi_cli ALL
|
||||
DEPENDS python_package
|
||||
${PY_PACKAGE_DIR}/__init__.py
|
||||
${PY_PACKAGE_DIR}/_version.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_cli.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_commands.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_helpers.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_init.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_logger.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_parser.py
|
||||
${PY_PACKAGE_DIR}/BDF.py)
|
||||
|
||||
install(
|
||||
FILES _version.py
|
||||
amdsmi_commands.py
|
||||
amdsmi_helpers.py
|
||||
amdsmi_init.py
|
||||
amdsmi_logger.py
|
||||
amdsmi_parser.py
|
||||
BDF.py
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli)
|
||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE_DIR}
|
||||
DESTINATION ${PY_CLI_INSTALL_DIR})
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
||||
GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE_DIR}/amdsmi_cli.py
|
||||
DESTINATION ${PY_CLI_INSTALL_DIR}/${PY_PACKAGE_DIR})
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
# symlink amdsmi_cli.py to amd-smi
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
add_custom_target(
|
||||
link_amdsmi_cli ALL
|
||||
DEPENDS amdsmi_cli
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
../${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli/amdsmi_cli.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi)
|
||||
|
||||
add_custom_target(
|
||||
link_gpuvsmi_cli ALL
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
../${PY_CLI_INSTALL_DIR}/${PY_PACKAGE_DIR}/amdsmi_cli.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/amd-smi
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
../${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli/amdsmi_cli.py
|
||||
amd-smi
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
@@ -29,6 +29,8 @@ import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.append(f'{Path(__file__).resolve().parent}/../../share/amd_smi')
|
||||
|
||||
import amdsmi as amdsmi_interface
|
||||
|
||||
# Using basic python logging for user errors and development
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Advanced Micro Devices. All rights reserved.
|
||||
#
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
set(clang_ver 14.0)
|
||||
set(ctypeslib_ver 2.3.2)
|
||||
|
||||
set(PY_BUILD_DIR "python_package" CACHE STRING "")
|
||||
set(PY_BUILD_DIR "python_package")
|
||||
# amdsmi part of this string is the directory containing all python files
|
||||
# additionally defined in pyproject.toml
|
||||
set(PY_PACKAGE_DIR "${PY_BUILD_DIR}/amdsmi" CACHE STRING "")
|
||||
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)
|
||||
find_package(Python3 3.7 COMPONENTS Interpreter Development)
|
||||
|
||||
# WARN: This is a HACK to pass compile on AMD rhel8 CI systems!
|
||||
# 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: drop python3.6 support
|
||||
# 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!")
|
||||
@@ -23,44 +24,14 @@ if(NOT Python3_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check if virtualenv is installed
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" -m pip show virtualenv
|
||||
ERROR_VARIABLE VIRTUALENV_NOT_FOUND)
|
||||
if(VIRTUALENV_NOT_FOUND)
|
||||
message(FATAL_ERROR "Python virtualenv is not installed!
|
||||
${VIRTUALENV_NOT_FOUND}
|
||||
Please run:
|
||||
${Python3_EXECUTABLE} -m pip install virtualenv")
|
||||
endif()
|
||||
|
||||
|
||||
# set up the Python environment
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" -m venv "${CMAKE_CURRENT_BINARY_DIR}/venv")
|
||||
|
||||
# venv trick borrowed from:
|
||||
# https://discourse.cmake.org/t/possible-to-create-a-python-virtual-env-from-cmake-and-then-find-it-with-findpython3/1132
|
||||
# update the environment with VIRTUAL_ENV variable(mimic the activate script)
|
||||
set(ENV{VIRTUAL_ENV} "${CMAKE_CURRENT_BINARY_DIR}/venv")
|
||||
# change the context of the search
|
||||
set(Python3_FIND_VIRTUALENV FIRST)
|
||||
# unset Python3_EXECUTABLE because it is also an input variable(see documentation, Artifacts Specification section)
|
||||
unset(Python3_EXECUTABLE)
|
||||
# launch a new search
|
||||
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})
|
||||
|
||||
# TODO: Figure out how python-clang and clang are related
|
||||
# Currently only a very specific combination works
|
||||
|
||||
# try to find clang of the right version
|
||||
set(GOOD_CLANG_FOUND FALSE)
|
||||
find_program(clang NAMES clang)
|
||||
if(clang STREQUAL "clang-NOTFOUND")
|
||||
message(AUTHOR_WARNING "NO CLANG FOUND!")
|
||||
else()
|
||||
# only try to re-generate amdsmi_wrapper.py if BUILD_WRAPPER is on/true
|
||||
if(BUILD_WRAPPER)
|
||||
find_program(clang NAMES clang REQUIRED)
|
||||
# extract clang version manually because find_package(clang) doesn't work
|
||||
execute_process(COMMAND ${clang} --version OUTPUT_VARIABLE clang_full_version_string)
|
||||
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
|
||||
@@ -68,12 +39,13 @@ else()
|
||||
message("GOOD CLANG VERSION: ${CLANG_VERSION_STRING}")
|
||||
set(GOOD_CLANG_FOUND TRUE)
|
||||
else()
|
||||
message(AUTHOR_WARNING "${clang} VERSION TOO OLD!: ${CLANG_VERSION_STRING}")
|
||||
message(FATAL_ERROR "${clang} VERSION TOO OLD!: ${CLANG_VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT GOOD_CLANG_FOUND)
|
||||
# keep old wrapper because no clang found
|
||||
message(AUTHOR_WARNING "A wrapper will not be generated! Using old wrapper instead.")
|
||||
message(AUTHOR_WARNING "A wrapper will not be re-generated! Using old wrapper instead.\nSet -DBUILD_WRAPPER=ON to re-build the wrapper")
|
||||
add_custom_command(
|
||||
OUTPUT amdsmi_wrapper.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_wrapper.py
|
||||
@@ -85,8 +57,11 @@ if(NOT GOOD_CLANG_FOUND)
|
||||
s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g
|
||||
${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py
|
||||
COMMAND mkdir -p ${PY_PACKAGE_DIR}
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
|
||||
else()
|
||||
add_custom_target(
|
||||
python_pre_reqs
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install clang==${clang_ver} ctypeslib2==${ctypeslib_ver})
|
||||
# generate new wrapper
|
||||
configure_file(${PROJECT_SOURCE_DIR}/tools/generator.py generator.py @ONLY COPYONLY)
|
||||
add_custom_command(
|
||||
@@ -106,14 +81,14 @@ else()
|
||||
s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g
|
||||
${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py
|
||||
COMMAND mkdir -p ${PY_PACKAGE_DIR}
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/)
|
||||
endif()
|
||||
|
||||
add_custom_target(
|
||||
python_wrapper
|
||||
DEPENDS amdsmi_wrapper.py)
|
||||
|
||||
# symlinking instead of copying avoids unnecessarry regeneration of packaged files
|
||||
# hard-linking instead of copying avoids unnecessarry regeneration of packaged files
|
||||
add_custom_command(
|
||||
OUTPUT ${PY_BUILD_DIR}/pyproject.toml
|
||||
${PY_PACKAGE_DIR}/__init__.py
|
||||
@@ -122,33 +97,26 @@ add_custom_command(
|
||||
${PY_PACKAGE_DIR}/README.md
|
||||
${PY_PACKAGE_DIR}/LICENSE
|
||||
DEPENDS python_wrapper
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${PY_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -sf ${PROJECT_SOURCE_DIR}/LICENSE ${PY_PACKAGE_DIR}/)
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${PY_BUILD_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/
|
||||
COMMAND ln -Pf ${PROJECT_SOURCE_DIR}/LICENSE ${PY_PACKAGE_DIR}/)
|
||||
|
||||
# NOTE: changing this does not change the generated file!
|
||||
# it WILL break
|
||||
set(PY_PACKAGE "${PY_BUILD_DIR}/amdsmi-0.1-py3-none-any.whl")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PY_PACKAGE}
|
||||
add_custom_target(
|
||||
python_package ALL
|
||||
DEPENDS ${PY_BUILD_DIR}/pyproject.toml
|
||||
${PY_PACKAGE_DIR}/__init__.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_exception.py
|
||||
${PY_PACKAGE_DIR}/amdsmi_interface.py
|
||||
${PY_PACKAGE_DIR}/README.md
|
||||
${PY_PACKAGE_DIR}/LICENSE
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install wheel
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip wheel ./${PY_BUILD_DIR} --wheel-dir=${PY_BUILD_DIR})
|
||||
|
||||
add_custom_target(
|
||||
python_package ALL
|
||||
DEPENDS ${PY_PACKAGE})
|
||||
${PY_PACKAGE_DIR}/LICENSE)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE}
|
||||
DESTINATION ${SHARE_INSTALL_PREFIX})
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/pyproject.toml
|
||||
DESTINATION ${PY_WRAPPER_INSTALL_DIR})
|
||||
|
||||
install(
|
||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PY_PACKAGE_DIR}
|
||||
DESTINATION ${PY_WRAPPER_INSTALL_DIR})
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
import os
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# TARGET arch is: ['-I/usr/lib/llvm-14/lib/clang/14.0.0/include']
|
||||
@@ -27,10 +28,8 @@
|
||||
# POINTER_SIZE is: 8
|
||||
# LONGDOUBLE_SIZE is: 16
|
||||
#
|
||||
|
||||
import os
|
||||
import ctypes
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
c_int128 = ctypes.c_ubyte*16
|
||||
c_uint128 = c_int128
|
||||
@@ -168,7 +167,7 @@ def char_pointer_cast(string, encoding='utf-8'):
|
||||
|
||||
|
||||
_libraries = {}
|
||||
|
||||
from pathlib import Path
|
||||
libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so")
|
||||
libamd_smi_optrocm = Path("/opt/rocm/lib/libamd_smi.so")
|
||||
libamd_smi_parent_dir = Path(__file__).resolve().parent / "libamd_smi.so"
|
||||
|
||||
Ссылка в новой задаче
Block a user