Merged
[feat]: package hixl Python binding as wheel with __init__.py and platform-tagged .so #903
zhaozhihuiAdd on Aug 15
[feat]: package hixl Python binding as wheel with __init__.py and platform-tagged .so #903
Merged
Merged fromzhaozhihui/hixlfeat/hixl-python-wheel-packageintocann/hixlmaster
Total: 12 files changed+183-53
| @@ -15,7 +15,7 @@ unset PYTHONPATH | |||
| 15 | export PIP_BREAK_SYSTEM_PACKAGES=1 | 15 | export PIP_BREAK_SYSTEM_PACKAGES=1 |
| 16 | 16 | ||
| 17 | WHL_LLM_DATADIST="${sourcedir}/hixl/lib/llm_datadist-0.0.1-py3-none-any.whl" | 17 | WHL_LLM_DATADIST="${sourcedir}/hixl/lib/llm_datadist-0.0.1-py3-none-any.whl" |
| 18 | -PYTHON_HIXL_SO="${sourcedir}/hixl/lib/hixl.so" | 18 | +PYTHON_HIXL_WHL=$(find "${sourcedir}/hixl/lib" -name "hixl-*.whl" -type f 2>/dev/null | head -1) |
| 19 | 19 | ||
| 20 | run_pip() { python3 -m pip "$@" || pip3 "$@"; } | 20 | run_pip() { python3 -m pip "$@" || pip3 "$@"; } |
| 21 | 21 | ||
| @@ -49,20 +49,9 @@ set_file_chmod() { | |||
| 49 | 49 | ||
| 50 | [ -f "${WHL_LLM_DATADIST}" ] && echo "[hixl] installing ${WHL_LLM_DATADIST}" && run_pip install --disable-pip-version-check --upgrade --no-deps --force-reinstall -t "${WHL_INSTALL_DIR_PATH}" "${WHL_LLM_DATADIST}" || true | 50 | [ -f "${WHL_LLM_DATADIST}" ] && echo "[hixl] installing ${WHL_LLM_DATADIST}" && run_pip install --disable-pip-version-check --upgrade --no-deps --force-reinstall -t "${WHL_INSTALL_DIR_PATH}" "${WHL_LLM_DATADIST}" || true |
| 51 | 51 | ||
| 52 | -if [ -f "${PYTHON_HIXL_SO}" ]; then | 52 | +if [ -n "${PYTHON_HIXL_WHL}" ] && [ -f "${PYTHON_HIXL_WHL}" ]; then |
| 53 | - mkdir -p "${WHL_INSTALL_DIR_PATH}" | 53 | + echo "[hixl] installing ${PYTHON_HIXL_WHL}" |
| 54 | - echo "[hixl] installing ${PYTHON_HIXL_SO}" | 54 | + run_pip install --disable-pip-version-check --upgrade --no-deps --force-reinstall -t "${WHL_INSTALL_DIR_PATH}" "${PYTHON_HIXL_WHL}" |
| 55 | - cp -f "${PYTHON_HIXL_SO}" "${WHL_INSTALL_DIR_PATH}/" | ||
| 56 | - if [ $? -ne 0 ]; then | ||
| 57 | - echo "[hixl][ERROR] copy hixl.so to ${WHL_INSTALL_DIR_PATH}/ failed" | ||
| 58 | - exit 1 | ||
| 59 | - fi | ||
| 60 | - mkdir -p "${WHL_INSTALL_DIR_PATH}/hixl" | ||
| 61 | - ln -sf ../hixl.so "${WHL_INSTALL_DIR_PATH}/hixl/hixl.so" | ||
| 62 | - if [ $? -ne 0 ]; then | ||
| 63 | - echo "[hixl][ERROR] create softlink hixl.so under ${WHL_INSTALL_DIR_PATH}/hixl/ failed" | ||
| 64 | - exit 1 | ||
| 65 | - fi | ||
| 66 | fi | 55 | fi |
| 67 | 56 | ||
| 68 | if [ -d "${WHL_INSTALL_DIR_PATH}" ]; then | 57 | if [ -d "${WHL_INSTALL_DIR_PATH}" ]; then |
| @@ -15,10 +15,10 @@ export PYTHONPATH="${WHL_INSTALL_DIR_PATH}" | |||
| 15 | export PIP_BREAK_SYSTEM_PACKAGES=1 | 15 | export PIP_BREAK_SYSTEM_PACKAGES=1 |
| 16 | 16 | ||
| 17 | pip3 uninstall -y "llm_datadist" >/dev/null 2>&1 || true | 17 | pip3 uninstall -y "llm_datadist" >/dev/null 2>&1 || true |
| 18 | +pip3 uninstall -y "hixl" >/dev/null 2>&1 || true | ||
| 18 | 19 | ||
| 19 | rm -fr "${WHL_INSTALL_DIR_PATH}/llm_datadist" "${WHL_INSTALL_DIR_PATH}/llm_datadist-"*.dist-info 2>/dev/null | 20 | rm -fr "${WHL_INSTALL_DIR_PATH}/llm_datadist" "${WHL_INSTALL_DIR_PATH}/llm_datadist-"*.dist-info 2>/dev/null |
| 20 | -rm -f "${WHL_INSTALL_DIR_PATH}/hixl.so" 2>/dev/null | 21 | +rm -fr "${WHL_INSTALL_DIR_PATH}/hixl" "${WHL_INSTALL_DIR_PATH}/hixl-"*.dist-info 2>/dev/null |
| 21 | -rm -fr "${WHL_INSTALL_DIR_PATH}/hixl" 2>/dev/null | ||
| 22 | 22 | ||
| 23 | remove_empty_dir() { | 23 | remove_empty_dir() { |
| 24 | local dir="$1" | 24 | local dir="$1" |
| @@ -108,8 +108,8 @@ python_dir_chmod_reset "$WHL_SOFTLINK_INSTALL_DIR_PATH" | |||
| 108 | 108 | ||
| 109 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist" | 109 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist" |
| 110 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist-*.dist-info" | 110 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist-*.dist-info" |
| 111 | -create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl.so" | ||
| 112 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl" | 111 | create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl" |
| 112 | +create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl-*.dist-info" | ||
| 113 | 113 | ||
| 114 | python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH" | 114 | python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH" |
| 115 | python_dir_chmod_set "$(dirname $WHL_SOFTLINK_INSTALL_DIR_PATH)" | 115 | python_dir_chmod_set "$(dirname $WHL_SOFTLINK_INSTALL_DIR_PATH)" |
| @@ -324,7 +324,7 @@ clear_kernel_cache_dir() { | |||
| 324 | 324 | ||
| 325 | WHL_INSTALL_DIR_PATH="${common_parse_dir}/python/site-packages" | 325 | WHL_INSTALL_DIR_PATH="${common_parse_dir}/python/site-packages" |
| 326 | PYTHON_LLM_DATADIST_WHL="${sourcedir}/lib/llm_datadist-0.0.1-py3-none-any.whl" | 326 | PYTHON_LLM_DATADIST_WHL="${sourcedir}/lib/llm_datadist-0.0.1-py3-none-any.whl" |
| 327 | -PYTHON_HIXL_SO="${sourcedir}/lib/hixl.so" | 327 | +PYTHON_HIXL_WHL=$(find "${sourcedir}/lib" -name "hixl-*.whl" -type f 2>/dev/null | head -1) |
| 328 | 328 | ||
| 329 | custom_install() { | 329 | custom_install() { |
| 330 | if [ ! -d "$common_parse_dir/hixl" ]; then | 330 | if [ ! -d "$common_parse_dir/hixl" ]; then |
| @@ -343,24 +343,14 @@ custom_install() { | |||
| 343 | log "INFO" "install llm_datadist extension module begin..." | 343 | log "INFO" "install llm_datadist extension module begin..." |
| 344 | hixl_install_package "${PYTHON_LLM_DATADIST_WHL}" "${WHL_INSTALL_DIR_PATH}" | 344 | hixl_install_package "${PYTHON_LLM_DATADIST_WHL}" "${WHL_INSTALL_DIR_PATH}" |
| 345 | log "INFO" "the llm_datadist extension module installed successfully!" | 345 | log "INFO" "the llm_datadist extension module installed successfully!" |
| 346 | - log "INFO" "install hixl begin..." | 346 | + log "INFO" "install hixl extension module begin..." |
| 347 | - cp -f "${PYTHON_HIXL_SO}" "${WHL_INSTALL_DIR_PATH}/" | 347 | + hixl_install_package "${PYTHON_HIXL_WHL}" "${WHL_INSTALL_DIR_PATH}" |
| 348 | - if [ $? -ne 0 ]; then | 348 | + log "INFO" "the hixl extension module installed successfully!" |
| 349 | - log "ERROR" "copy hixl.so to ${WHL_INSTALL_DIR_PATH}/ failed" | ||
| 350 | - exit 1 | ||
| 351 | - fi | ||
| 352 | - mkdir -p "${WHL_INSTALL_DIR_PATH}/hixl" | ||
| 353 | - ln -sf ../hixl.so "${WHL_INSTALL_DIR_PATH}/hixl/hixl.so" | ||
| 354 | - if [ $? -ne 0 ]; then | ||
| 355 | - log "ERROR" "create softlink hixl.so under ${WHL_INSTALL_DIR_PATH}/hixl/ failed" | ||
| 356 | - exit 1 | ||
| 357 | - fi | ||
| 358 | - log "INFO" "the hixl installed successfully!" | ||
| 359 | 349 | ||
| 360 | if [ "${pylocal}" = "y" ]; then | 350 | if [ "${pylocal}" = "y" ]; then |
| 361 | log "INFO" "please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH}." | 351 | log "INFO" "please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH}." |
| 362 | else | 352 | else |
| 363 | - log "INFO" "llm_datadist is installed in python default path. hixl.so is installed in ${WHL_INSTALL_DIR_PATH}, please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH} to import hixl. It is recommended to install using the '--pylocal' parameter for a unified install location." | 353 | + log "INFO" "llm_datadist and hixl are installed in python default path. It is recommended to install using the '--pylocal' parameter for a unified install location." |
| 364 | fi | 354 | fi |
| 365 | 355 | ||
| 366 | if [ "x$stage" = "xinstall" ]; then | 356 | if [ "x$stage" = "xinstall" ]; then |
| @@ -93,8 +93,8 @@ python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH" | |||
| 93 | 93 | ||
| 94 | remove_softlink "llm_datadist" | 94 | remove_softlink "llm_datadist" |
| 95 | remove_softlink "llm_datadist-*.dist-info" | 95 | remove_softlink "llm_datadist-*.dist-info" |
| 96 | -remove_softlink "hixl.so" | ||
| 97 | remove_softlink "hixl" | 96 | remove_softlink "hixl" |
| 97 | +remove_softlink "hixl-*.dist-info" | ||
| 98 | 98 | ||
| 99 | remove_empty_dir "$WHL_SOFTLINK_INSTALL_DIR_PATH" | 99 | remove_empty_dir "$WHL_SOFTLINK_INSTALL_DIR_PATH" |
| 100 | remove_empty_dir "$install_path/$latest_dir/python" | 100 | remove_empty_dir "$install_path/$latest_dir/python" |
| @@ -124,15 +124,15 @@ remove_whl_residuals() { | |||
| 124 | whl_uninstall_package() { | 124 | whl_uninstall_package() { |
| 125 | local _module="$1" | 125 | local _module="$1" |
| 126 | local _module_path="$2" | 126 | local _module_path="$2" |
| 127 | - local _hixl_whl="llm_datadist" | 127 | + local _whl_name="$3" |
| 128 | local ret=0 | 128 | local ret=0 |
| 129 | 129 | ||
| 130 | - if [ ! -d "${_module_path}/${_hixl_whl}" ]; then | 130 | + if [ ! -d "${_module_path}/${_whl_name}" ]; then |
| 131 | - pip3 show "${_hixl_whl}" > /dev/null 2>&1 | 131 | + pip3 show "${_whl_name}" > /dev/null 2>&1 |
| 132 | if [ $? -ne 0 ]; then | 132 | if [ $? -ne 0 ]; then |
| 133 | log "WARNING" "${_module} does not exist." | 133 | log "WARNING" "${_module} does not exist." |
| 134 | else | 134 | else |
| 135 | - pip3 uninstall -y "${_hixl_whl}" > /dev/null 2>&1 | 135 | + pip3 uninstall -y "${_whl_name}" > /dev/null 2>&1 |
| 136 | ret=$? | 136 | ret=$? |
| 137 | if [ $ret -ne 0 ]; then | 137 | if [ $ret -ne 0 ]; then |
| 138 | log "WARNING" "pip uninstall ${_module} failed, error code: $ret." | 138 | log "WARNING" "pip uninstall ${_module} failed, error code: $ret." |
| @@ -140,20 +140,20 @@ whl_uninstall_package() { | |||
| 140 | log "INFO" "${_module} uninstalled by pip successfully!" | 140 | log "INFO" "${_module} uninstalled by pip successfully!" |
| 141 | fi | 141 | fi |
| 142 | fi | 142 | fi |
| 143 | - remove_whl_residuals "${_module_path}" "${_hixl_whl}" | 143 | + remove_whl_residuals "${_module_path}" "${_whl_name}" |
| 144 | else | 144 | else |
| 145 | export PYTHONPATH="${_module_path}" | 145 | export PYTHONPATH="${_module_path}" |
| 146 | - pip3 uninstall -y "${_hixl_whl}" > /dev/null 2>&1 | 146 | + pip3 uninstall -y "${_whl_name}" > /dev/null 2>&1 |
| 147 | ret=$? | 147 | ret=$? |
| 148 | if [ $ret -ne 0 ]; then | 148 | if [ $ret -ne 0 ]; then |
| 149 | log "WARNING" "pip uninstall ${_module} failed, error code: $ret, clean install path residuals instead." | 149 | log "WARNING" "pip uninstall ${_module} failed, error code: $ret, clean install path residuals instead." |
| 150 | else | 150 | else |
| 151 | log "INFO" "${_module} uninstalled by pip successfully!" | 151 | log "INFO" "${_module} uninstalled by pip successfully!" |
| 152 | fi | 152 | fi |
| 153 | - remove_whl_residuals "${_module_path}" "${_hixl_whl}" | 153 | + remove_whl_residuals "${_module_path}" "${_whl_name}" |
| 154 | fi | 154 | fi |
| 155 | 155 | ||
| 156 | - if [ -d "${_module_path}/${_hixl_whl}" ] || ls "${_module_path}/${_hixl_whl}-"*.dist-info > /dev/null 2>&1; then | 156 | + if [ -d "${_module_path}/${_whl_name}" ] || ls "${_module_path}/${_whl_name}-"*.dist-info > /dev/null 2>&1; then |
| 157 | log "ERROR" "remove ${_module} residual files failed." | 157 | log "ERROR" "remove ${_module} residual files failed." |
| 158 | exit 1 | 158 | exit 1 |
| 159 | fi | 159 | fi |
| @@ -217,14 +217,16 @@ custom_uninstall() { | |||
| 217 | chmod +w -R "$curpath" 2> /dev/null | 217 | chmod +w -R "$curpath" 2> /dev/null |
| 218 | chmod +w -R "${WHL_INSTALL_DIR_PATH}/llm_datadist" 2> /dev/null | 218 | chmod +w -R "${WHL_INSTALL_DIR_PATH}/llm_datadist" 2> /dev/null |
| 219 | chmod +w -R "${WHL_INSTALL_DIR_PATH}/llm_datadist-0.0.1.dist-info" 2> /dev/null | 219 | chmod +w -R "${WHL_INSTALL_DIR_PATH}/llm_datadist-0.0.1.dist-info" 2> /dev/null |
| 220 | + chmod +w -R "${WHL_INSTALL_DIR_PATH}/hixl" 2> /dev/null | ||
| 221 | + chmod +w -R "${WHL_INSTALL_DIR_PATH}/hixl-"*.dist-info 2> /dev/null | ||
| 220 | 222 | ||
| 221 | - log "INFO" "uninstall hixl tool begin..." | 223 | + log "INFO" "uninstall llm_datadist begin..." |
| 222 | - whl_uninstall_package "${HIXL_NAME}" "${WHL_INSTALL_DIR_PATH}" | 224 | + whl_uninstall_package "llm_datadist" "${WHL_INSTALL_DIR_PATH}" "llm_datadist" |
| 223 | - log "INFO" "hixl tool uninstalled successfully!" | 225 | + log "INFO" "llm_datadist uninstalled successfully!" |
| 224 | 226 | ||
| 225 | - rm -f "${WHL_INSTALL_DIR_PATH}/hixl.so" 2> /dev/null | 227 | + log "INFO" "uninstall hixl begin..." |
| 226 | - rm -rf "${WHL_INSTALL_DIR_PATH}/hixl" 2> /dev/null | 228 | + whl_uninstall_package "${HIXL_NAME}" "${WHL_INSTALL_DIR_PATH}" "hixl" |
| 227 | - log "INFO" "hixl module uninstalled successfully!" | 229 | + log "INFO" "hixl extension module uninstalled successfully!" |
| 228 | fi | 230 | fi |
| 229 | 231 | ||
| 230 | remove_empty_dir "${common_parse_dir}/hixl/python" | 232 | remove_empty_dir "${common_parse_dir}/hixl/python" |
| @@ -106,6 +106,10 @@ chmod_end() { | |||
| 106 | chmod_recur "$current_install_path/python/site-packages/llm_datadist" 550 file | 106 | chmod_recur "$current_install_path/python/site-packages/llm_datadist" 550 file |
| 107 | chmod_recur "$current_install_path/python/site-packages/llm_datadist-0.0.1.dist-info" 550 dir | 107 | chmod_recur "$current_install_path/python/site-packages/llm_datadist-0.0.1.dist-info" 550 dir |
| 108 | chmod_recur "$current_install_path/python/site-packages/llm_datadist-0.0.1.dist-info" 550 file | 108 | chmod_recur "$current_install_path/python/site-packages/llm_datadist-0.0.1.dist-info" 550 file |
| 109 | + chmod_recur "$current_install_path/python/site-packages/hixl" 550 dir | ||
| 110 | + chmod_recur "$current_install_path/python/site-packages/hixl" 550 file | ||
| 111 | + chmod_recur "$current_install_path/python/site-packages/hixl-"*.dist-info 550 dir | ||
| 112 | + chmod_recur "$current_install_path/python/site-packages/hixl-"*.dist-info 550 file | ||
| 109 | chmod_recur "$current_install_path/python/site-packages/LICENSE" 440 file | 113 | chmod_recur "$current_install_path/python/site-packages/LICENSE" 440 file |
| 110 | fi | 114 | fi |
| 111 | 115 | ||
| @@ -4,12 +4,13 @@ | |||
| 4 | # CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | if (NOT ENABLE_TEST) | 11 | if (NOT ENABLE_TEST) |
| 12 | set(CMAKE_SKIP_RPATH TRUE) | 12 | set(CMAKE_SKIP_RPATH TRUE) |
| 13 | + | ||
| 13 | add_library(hixl MODULE | 14 | add_library(hixl MODULE |
| 14 | hixl_py.cc) | 15 | hixl_py.cc) |
| 15 | 16 | ||
| @@ -48,7 +49,22 @@ if (NOT ENABLE_TEST) | |||
| 48 | -s | 49 | -s |
| 49 | ) | 50 | ) |
| 50 | 51 | ||
| 51 | - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hixl.so | 52 | +add_custom_target(hixl_python ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hixl-0.0.1-py3-none-any.whl) |
| 53 | +add_custom_command( | ||
| 54 | + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hixl-0.0.1-py3-none-any.whl | ||
| 55 | + COMMAND ${CMAKE_COMMAND} -E echo "package hixl whl start" | ||
| 56 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl | ||
| 57 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl/setup.py | ||
| 58 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.in ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl/ | ||
| 59 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/hixl ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl/hixl | ||
| 60 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/hixl.so ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl/hixl/ | ||
| 61 | + COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl ${HI_PYTHON} setup.py bdist_wheel | ||
| 62 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/wheel_hixl/dist/hixl-0.0.1-py3-none-any.whl ${CMAKE_CURRENT_BINARY_DIR}/ | ||
| 63 | + COMMAND ${CMAKE_COMMAND} -E echo "package hixl whl end" | ||
| 64 | + DEPENDS version_hixl_info hixl | ||
| 65 | +) | ||
| 66 | + | ||
| 67 | + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hixl-0.0.1-py3-none-any.whl | ||
| 52 | DESTINATION ${INSTALL_LIBRARY_DIR} | 68 | DESTINATION ${INSTALL_LIBRARY_DIR} |
| 53 | COMPONENT hixl | 69 | COMPONENT hixl |
| 54 | ) | 70 | ) |
| @@ -0,0 +1 @@ | |||
| 1 | +recursive-include hixl *.so | ||
| @@ -0,0 +1,105 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 5 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 6 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 7 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 8 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 9 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 10 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 11 | +# ---------------------------------------------------------------------------- | ||
| 12 | + | ||
| 13 | +from hixl.hixl import ( | ||
| 14 | + SUCCESS, | ||
| 15 | + PARAM_INVALID, | ||
| 16 | + TIMEOUT, | ||
| 17 | + NOT_CONNECTED, | ||
| 18 | + ALREADY_CONNECTED, | ||
| 19 | + NOTIFY_FAILED, | ||
| 20 | + UNSUPPORTED, | ||
| 21 | + FAILED, | ||
| 22 | + RESOURCE_EXHAUSTED, | ||
| 23 | + OPTION_ENABLE_USE_FABRIC_MEM, | ||
| 24 | + OPTION_RDMA_TRAFFIC_CLASS, | ||
| 25 | + OPTION_RDMA_SERVICE_LEVEL, | ||
| 26 | + OPTION_BUFFER_POOL, | ||
| 27 | + OPTION_GLOBAL_RESOURCE_CONFIG, | ||
| 28 | + OPTION_AUTO_CONNECT, | ||
| 29 | + OPTION_LOCAL_COMM_RES, | ||
| 30 | + FEATURE_SUPPORTED, | ||
| 31 | + FEATURE_NOT_SUPPORTED, | ||
| 32 | + MemType, | ||
| 33 | + MEM_DEVICE, | ||
| 34 | + MEM_HOST, | ||
| 35 | + TransferOp, | ||
| 36 | + READ, | ||
| 37 | + WRITE, | ||
| 38 | + TransferStatus, | ||
| 39 | + AsyncConnectStatus, | ||
| 40 | + NOT_CONNECT, | ||
| 41 | + CONNECT_PENDING, | ||
| 42 | + CONNECTING, | ||
| 43 | + CONNECTED, | ||
| 44 | + CONNECT_FAILED, | ||
| 45 | + DISCONNECT_PENDING, | ||
| 46 | + DISCONNECTING, | ||
| 47 | + FeatureType, | ||
| 48 | + AUTO_CONNECT, | ||
| 49 | + CLIENT_SERVER_COMM, | ||
| 50 | + MemDesc, | ||
| 51 | + TransferOpDesc, | ||
| 52 | + TransferArgs, | ||
| 53 | + GetTransferStatusArgs, | ||
| 54 | + TransferResult, | ||
| 55 | + NotifyDesc, | ||
| 56 | + Hixl, | ||
| 57 | + get_capability, | ||
| 58 | +) | ||
| 59 | + | ||
| 60 | +__all__ = [ | ||
| 61 | + "SUCCESS", | ||
| 62 | + "PARAM_INVALID", | ||
| 63 | + "TIMEOUT", | ||
| 64 | + "NOT_CONNECTED", | ||
| 65 | + "ALREADY_CONNECTED", | ||
| 66 | + "NOTIFY_FAILED", | ||
| 67 | + "UNSUPPORTED", | ||
| 68 | + "FAILED", | ||
| 69 | + "RESOURCE_EXHAUSTED", | ||
| 70 | + "OPTION_ENABLE_USE_FABRIC_MEM", | ||
| 71 | + "OPTION_RDMA_TRAFFIC_CLASS", | ||
| 72 | + "OPTION_RDMA_SERVICE_LEVEL", | ||
| 73 | + "OPTION_BUFFER_POOL", | ||
| 74 | + "OPTION_GLOBAL_RESOURCE_CONFIG", | ||
| 75 | + "OPTION_AUTO_CONNECT", | ||
| 76 | + "OPTION_LOCAL_COMM_RES", | ||
| 77 | + "FEATURE_SUPPORTED", | ||
| 78 | + "FEATURE_NOT_SUPPORTED", | ||
| 79 | + "MemType", | ||
| 80 | + "MEM_DEVICE", | ||
| 81 | + "MEM_HOST", | ||
| 82 | + "TransferOp", | ||
| 83 | + "READ", | ||
| 84 | + "WRITE", | ||
| 85 | + "TransferStatus", | ||
| 86 | + "AsyncConnectStatus", | ||
| 87 | + "NOT_CONNECT", | ||
| 88 | + "CONNECT_PENDING", | ||
| 89 | + "CONNECTING", | ||
| 90 | + "CONNECTED", | ||
| 91 | + "CONNECT_FAILED", | ||
| 92 | + "DISCONNECT_PENDING", | ||
| 93 | + "DISCONNECTING", | ||
| 94 | + "FeatureType", | ||
| 95 | + "AUTO_CONNECT", | ||
| 96 | + "CLIENT_SERVER_COMM", | ||
| 97 | + "MemDesc", | ||
| 98 | + "TransferOpDesc", | ||
| 99 | + "TransferArgs", | ||
| 100 | + "GetTransferStatusArgs", | ||
| 101 | + "TransferResult", | ||
| 102 | + "NotifyDesc", | ||
| 103 | + "Hixl", | ||
| 104 | + "get_capability", | ||
| 105 | +] | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 5 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 6 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 7 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 8 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 9 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 10 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 11 | +# ---------------------------------------------------------------------------- | ||
| 12 | + | ||
| 13 | +from setuptools import setup | ||
| 14 | +from setuptools import find_packages | ||
| 15 | + | ||
| 16 | +setup( | ||
| 17 | + name="hixl", | ||
| 18 | + version="0.0.1", | ||
| 19 | + description="HIXL Python API", | ||
| 20 | + packages=find_packages(), | ||
| 21 | + include_package_data=True, | ||
| 22 | + ext_modules=[], | ||
| 23 | +) | ||
| @@ -458,7 +458,7 @@ run() { | |||
| 458 | unset LD_PRELOAD | 458 | unset LD_PRELOAD |
| 459 | cp ${BUILD_PATH}/tests/depends/python/llm_datadist_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/ | 459 | cp ${BUILD_PATH}/tests/depends/python/llm_datadist_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/ |
| 460 | cp ${BUILD_PATH}/tests/depends/python/metadef_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/ | 460 | cp ${BUILD_PATH}/tests/depends/python/metadef_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/ |
| 461 | - cp ${BUILD_PATH}/tests/depends/python/hixl.so ${BASEPATH}/src/python/hixl_py/ | 461 | + cp ${BUILD_PATH}/tests/depends/python/hixl*.so ${BASEPATH}/src/python/hixl_py/hixl/ |
| 462 | cp -r ${BASEPATH}/tests/python ./ | 462 | cp -r ${BASEPATH}/tests/python ./ |
| 463 | PYTHON_ORIGINAL_PATH=$PYTHONPATH | 463 | PYTHON_ORIGINAL_PATH=$PYTHONPATH |
| 464 | export PYTHONPATH=${BASEPATH}/src/python/llm_datadist/:${BASEPATH}/src/python/hixl_py/ | 464 | export PYTHONPATH=${BASEPATH}/src/python/llm_datadist/:${BASEPATH}/src/python/hixl_py/ |
| @@ -475,11 +475,11 @@ run() { | |||
| 475 | if [[ "$?" -ne 0 ]]; then | 475 | if [[ "$?" -ne 0 ]]; then |
| 476 | echo "!!! PY TEST FAILED, PLEASE CHECK YOUR CHANGES !!!" | 476 | echo "!!! PY TEST FAILED, PLEASE CHECK YOUR CHANGES !!!" |
| 477 | rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so | 477 | rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so |
| 478 | - rm -f ${BASEPATH}/src/python/hixl_py/*.so | 478 | + rm -f ${BASEPATH}/src/python/hixl_py/hixl/*.so |
| 479 | exit 1; | 479 | exit 1; |
| 480 | fi | 480 | fi |
| 481 | rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so | 481 | rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so |
| 482 | - rm -f ${BASEPATH}/src/python/hixl_py/*.so | 482 | + rm -f ${BASEPATH}/src/python/hixl_py/hixl/*.so |
| 483 | 483 | ||
| 484 | if [[ "X$ENABLE_ASAN" = "XON" ]]; then | 484 | if [[ "X$ENABLE_ASAN" = "XON" ]]; then |
| 485 | unset LD_PRELOAD | 485 | unset LD_PRELOAD |
卸载打印两遍hixl卸载,应该把whl包名字打印出来