parent
60958d6b25
commit
2dd60b4ce3
@ -0,0 +1,185 @@
|
||||
# include dependency
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# set package information
|
||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_GENERATOR "External")
|
||||
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
|
||||
set(CPACK_EXTERNAL_ENABLE_STAGING true)
|
||||
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${CMAKE_SOURCE_DIR}/build/package/mindspore)
|
||||
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${CMAKE_SOURCE_DIR}/build/package/mindspore)
|
||||
if (ENABLE_GE)
|
||||
set(CPACK_MS_BACKEND "ge")
|
||||
set(CPACK_MS_PACKAGE_NAME "mindspore")
|
||||
elseif (ENABLE_GPU)
|
||||
set(CPACK_MS_BACKEND "ms")
|
||||
set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
|
||||
elseif (ENABLE_D)
|
||||
set(CPACK_MS_BACKEND "ms")
|
||||
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
|
||||
elseif (ENABLE_CPU)
|
||||
set(CPACK_MS_BACKEND "ms")
|
||||
set(CPACK_MS_PACKAGE_NAME "mindspore")
|
||||
else ()
|
||||
set(CPACK_MS_BACKEND "debug")
|
||||
set(CPACK_MS_PACKAGE_NAME "mindspore")
|
||||
endif ()
|
||||
include(CPack)
|
||||
|
||||
# set install path
|
||||
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_PY_DIR ".")
|
||||
set(INSTALL_LIB_DIR "lib")
|
||||
set(INSTALL_BASE_DIR ".")
|
||||
|
||||
# set package files
|
||||
install(
|
||||
TARGETS _c_expression
|
||||
DESTINATION ${INSTALL_BASE_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS mindspore_gvar
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
if (USE_GLOG)
|
||||
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libglog*)
|
||||
install(
|
||||
FILES ${GLOG_LIB_LIST}
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_MINDDATA)
|
||||
install(
|
||||
TARGETS _c_dataengine _c_mindrecord
|
||||
DESTINATION ${INSTALL_BASE_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE OPENCV_LIB_LIST
|
||||
${opencv_LIBPATH}/libopencv_core*
|
||||
${opencv_LIBPATH}/libopencv_imgcodecs*
|
||||
${opencv_LIBPATH}/libopencv_imgproc*
|
||||
)
|
||||
install(
|
||||
FILES ${OPENCV_LIB_LIST}
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_CPU)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.lib)
|
||||
endif ()
|
||||
install(
|
||||
FILES ${DNNL_LIB_LIST}
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_GPU)
|
||||
if (ENABLE_MPI)
|
||||
install(
|
||||
TARGETS _ms_mpi gpu_collective
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
|
||||
install(
|
||||
TARGETS gpu_queue
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT ENABLE_GE)
|
||||
if (ENABLE_D)
|
||||
if (DEFINED ENV{ASCEND_CUSTOM_PATH})
|
||||
set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
|
||||
else ()
|
||||
set(ASCEND_PATH /usr/local/Ascend)
|
||||
endif ()
|
||||
set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
|
||||
${CMAKE_BINARY_DIR}/graphengine/src/ge/common/libge_common.so
|
||||
${CMAKE_BINARY_DIR}/graphengine/src/ge/ge_runtime/libge_runtime.so
|
||||
${ASCEND_DRIVER_PATH}/libslog.so
|
||||
${ASCEND_DRIVER_PATH}/libc_sec.so
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
elseif (ENABLE_TESTCASES)
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_BINARY_DIR}/graphengine/src/common/graph/libgraph.so
|
||||
${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libslog.so
|
||||
${CMAKE_SOURCE_DIR}/graphengine/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}/libc_sec.so
|
||||
DESTINATION ${INSTALL_LIB_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# set python files
|
||||
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
|
||||
install(
|
||||
FILES ${MS_PY_LIST}
|
||||
DESTINATION ${INSTALL_PY_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/mindspore/nn
|
||||
${CMAKE_SOURCE_DIR}/mindspore/_extends
|
||||
${CMAKE_SOURCE_DIR}/mindspore/parallel
|
||||
${CMAKE_SOURCE_DIR}/mindspore/mindrecord
|
||||
${CMAKE_SOURCE_DIR}/mindspore/train
|
||||
${CMAKE_SOURCE_DIR}/mindspore/model_zoo
|
||||
${CMAKE_SOURCE_DIR}/mindspore/common
|
||||
${CMAKE_SOURCE_DIR}/mindspore/ops
|
||||
${CMAKE_SOURCE_DIR}/mindspore/communication
|
||||
DESTINATION ${INSTALL_PY_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
|
||||
if (ENABLE_GPU)
|
||||
install(
|
||||
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/_akg
|
||||
DESTINATION ${INSTALL_PY_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/incubator-tvm)
|
||||
install(
|
||||
DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/mindspore/incubator-tvm/topi/python/topi
|
||||
${CMAKE_SOURCE_DIR}/mindspore/incubator-tvm/python/tvm
|
||||
DESTINATION ${INSTALL_PY_DIR}/_akg
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/mindspore/dataset)
|
||||
install(
|
||||
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/dataset
|
||||
DESTINATION ${INSTALL_PY_DIR}
|
||||
COMPONENT mindspore
|
||||
)
|
||||
endif ()
|
@ -0,0 +1,92 @@
|
||||
# find exec
|
||||
find_package(Python3 3.7 COMPONENTS Interpreter Development)
|
||||
if (NOT Python3_FOUND)
|
||||
message("No python3 found.")
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
set(PYTHON ${Python3_EXECUTABLE})
|
||||
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
|
||||
|
||||
find_package(Git)
|
||||
if (NOT GIT_FOUND)
|
||||
message("No git found.")
|
||||
return ()
|
||||
endif ()
|
||||
set(GIT ${GIT_EXECUTABLE})
|
||||
|
||||
# set path
|
||||
set(MS_ROOT_DIR ${CPACK_PACKAGE_DIRECTORY}/../../)
|
||||
set(MS_PACK_ROOT_DIR ${MS_ROOT_DIR}/build/package)
|
||||
|
||||
# set package file name
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
if (PYTHON_VERSION MATCHES "3.7")
|
||||
set(PY_TAGS "cp37-cp37m")
|
||||
else ()
|
||||
message("Could not find 'Python 3.7'")
|
||||
return()
|
||||
endif ()
|
||||
string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
if (PYTHON_VERSION MATCHES "3.7")
|
||||
set(PY_TAGS "py37-none")
|
||||
else ()
|
||||
message("Could not find 'Python 3.7'")
|
||||
return()
|
||||
endif ()
|
||||
set(PLATFORM_TAG "any")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
if (PYTHON_VERSION MATCHES "3.7")
|
||||
set(PY_TAGS "cp37-cp37m")
|
||||
else ()
|
||||
message("Could not find 'Python 3.7'")
|
||||
return()
|
||||
endif ()
|
||||
set(PLATFORM_TAG "win_amd64")
|
||||
else ()
|
||||
message(FATAL_ERROR "other platform: ${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
|
||||
# get git commit id
|
||||
set(GIT_COMMIT_ID "")
|
||||
execute_process(
|
||||
COMMAND ${GIT} log --format='[sha1]:%h,[branch]:%d' -1
|
||||
OUTPUT_VARIABLE GIT_COMMIT_ID
|
||||
WORKING_DIRECTORY ${MS_ROOT_DIR}
|
||||
ERROR_QUIET)
|
||||
string(REPLACE " " "" GIT_COMMIT_ID ${GIT_COMMIT_ID})
|
||||
|
||||
set(ENV{BACKEND_POLICY} ${CPACK_MS_BACKEND})
|
||||
set(ENV{MS_PACKAGE_NAME} ${CPACK_MS_PACKAGE_NAME})
|
||||
set(ENV{COMMIT_ID} ${GIT_COMMIT_ID})
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYTHON} ${MS_ROOT_DIR}/setup.py "bdist_wheel"
|
||||
WORKING_DIRECTORY ${MS_PACK_ROOT_DIR}
|
||||
)
|
||||
|
||||
# finally
|
||||
set(PACKAGE_NAME ${CPACK_MS_PACKAGE_NAME})
|
||||
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
string(REPLACE "-" "_" PACKAGE_NAME ${PACKAGE_NAME})
|
||||
execute_process(
|
||||
COMMAND chmod -R 700 ${MS_PACK_ROOT_DIR}/mindspore/
|
||||
COMMAND chmod -R 700 ${MS_PACK_ROOT_DIR}/${PACKAGE_NAME}.egg-info/
|
||||
)
|
||||
endif ()
|
||||
|
||||
set(PACKAGE_NAME "mindspore")
|
||||
|
||||
file(GLOB WHL_FILE ${MS_PACK_ROOT_DIR}/dist/*.whl)
|
||||
get_filename_component(ORIGIN_FILE_NAME ${WHL_FILE} NAME)
|
||||
string(REPLACE "-" ";" ORIGIN_FILE_NAME ${ORIGIN_FILE_NAME})
|
||||
list(GET ORIGIN_FILE_NAME 1 VERSION)
|
||||
set(NEW_FILE_NAME ${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG}.whl)
|
||||
file(RENAME ${WHL_FILE} ${MS_PACK_ROOT_DIR}/${NEW_FILE_NAME})
|
||||
file(REMOVE_RECURSE ${MS_ROOT_DIR}/output)
|
||||
file(MAKE_DIRECTORY ${MS_ROOT_DIR}/output)
|
||||
file(COPY ${MS_PACK_ROOT_DIR}/${NEW_FILE_NAME} DESTINATION ${MS_ROOT_DIR}/output/)
|
||||
|
||||
file(SHA256 ${MS_ROOT_DIR}/output/${NEW_FILE_NAME} SHA256_VAR)
|
||||
file(WRITE ${MS_ROOT_DIR}/output/${NEW_FILE_NAME}.sha256 ${SHA256_VAR} " " ${NEW_FILE_NAME})
|
@ -1,128 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
BASEPATH=$(cd "$(dirname $0)"; pwd)
|
||||
echo "${BASEPATH}"
|
||||
cd "${BASEPATH}"
|
||||
BUILD_PATH="${BASEPATH}/build"
|
||||
PACKAGE_PATH="${BUILD_PATH}/package"
|
||||
OUTPUT_PATH="${BASEPATH}/output"
|
||||
|
||||
mk_new_dir() {
|
||||
local create_dir="$1" # the target to make
|
||||
|
||||
if [[ -d "${create_dir}" ]];then
|
||||
rm -rf "${create_dir}"
|
||||
fi
|
||||
|
||||
mkdir -pv "${create_dir}"
|
||||
}
|
||||
|
||||
to_lower () {
|
||||
echo "$1" | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
COMMIT_ID=$(git log --format='[sha1]:%h,[branch]:%d' -1 | sed 's/ //g')
|
||||
export COMMIT_ID
|
||||
|
||||
PYTHON=$(which python3)
|
||||
PYTHON_VERSION=$("${PYTHON}" -V 2>&1 | awk '{print $2}' | cut -d. -f-2)
|
||||
if [[ $(uname) == "Linux" ]]; then
|
||||
if [[ "${PYTHON_VERSION}" == "3.7" ]]; then
|
||||
PY_TAGS="cp37-cp37m"
|
||||
else
|
||||
echo "Could not find 'Python 3.7'"
|
||||
exit 1
|
||||
fi
|
||||
PLATFORM_TAG=$(to_lower "$(uname)_$(uname -m)")
|
||||
elif [[ $(uname) == "Darwin" ]]; then
|
||||
if [[ "${PYTHON_VERSION}" == "3.7" ]]; then
|
||||
PY_TAGS="py3-none"
|
||||
else
|
||||
echo "Could not find 'Python 3.7'"
|
||||
exit 1
|
||||
fi
|
||||
PLATFORM_TAG="any"
|
||||
fi
|
||||
echo "=========${BASEPATH}==================="
|
||||
mk_new_dir "${OUTPUT_PATH}"
|
||||
|
||||
#copy necessary file to pack_path
|
||||
cp ${BASEPATH}/mindspore/*.py "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/nn" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/_extends" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/parallel" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/mindrecord" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/train" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/model_zoo" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/common" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/ops" "${PACKAGE_PATH}/mindspore"
|
||||
cp -rf "${BUILD_PATH}/../mindspore/communication" "${PACKAGE_PATH}/mindspore"
|
||||
|
||||
if [[ "X$2" = "Xgpu" ]]; then
|
||||
echo "package _akg when gpu enable."
|
||||
cp -rf "${BASEPATH}/mindspore/_akg" "${PACKAGE_PATH}"
|
||||
if [[ -d "${BUILD_PATH}/mindspore/incubator-tvm" ]]; then
|
||||
cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/topi/python/topi" "${PACKAGE_PATH}/_akg"
|
||||
cp -rf "${BUILD_PATH}/mindspore/incubator-tvm/python/tvm" "${PACKAGE_PATH}/_akg"
|
||||
fi
|
||||
fi
|
||||
|
||||
# move dataset
|
||||
if [[ -d "${BASEPATH}/mindspore/dataset" ]]; then
|
||||
cp -rf "${BASEPATH}/mindspore/dataset" "${PACKAGE_PATH}/mindspore"
|
||||
fi
|
||||
|
||||
cd "${PACKAGE_PATH}"
|
||||
if [ -n "$1" ];then
|
||||
export BACKEND_POLICY=$1
|
||||
else
|
||||
export BACKEND_POLICY="ms"
|
||||
fi
|
||||
|
||||
# package name
|
||||
if [[ "X$1" = "Xge" ]]; then
|
||||
export MS_PACKAGE_NAME="mindspore"
|
||||
elif [[ "X$1" = "Xms" && "X$2" = "Xgpu" ]]; then
|
||||
export MS_PACKAGE_NAME="mindspore-gpu"
|
||||
elif [[ "X$1" = "Xms" && "X$2" = "Xascend" ]]; then
|
||||
export MS_PACKAGE_NAME="mindspore-ascend"
|
||||
elif [[ "X$1" = "Xms" && "X$2" = "Xcpu" ]]; then
|
||||
export MS_PACKAGE_NAME="mindspore"
|
||||
else
|
||||
export MS_PACKAGE_NAME="mindspore"
|
||||
fi
|
||||
|
||||
${PYTHON} "${BASEPATH}/setup.py" bdist_wheel
|
||||
|
||||
chmod -R 700 ${PACKAGE_PATH}/mindspore/
|
||||
chmod -R 700 ${PACKAGE_PATH}/${MS_PACKAGE_NAME//-/_}.egg-info/
|
||||
|
||||
# rename package
|
||||
PACKAGE_FULL_NAME=$(find "${PACKAGE_PATH}" -iname "*.whl")
|
||||
PACKAGE_BASE_NAME=$(echo ${PACKAGE_FULL_NAME} | awk -F / '{print $NF}' | awk -F - '{print $1"-"$2}')
|
||||
PACKAGE_BASE_NAME=${PACKAGE_BASE_NAME//_*-/-}
|
||||
|
||||
PACKAGE_NEW_NAME="${PACKAGE_BASE_NAME}-${PY_TAGS}-${PLATFORM_TAG}.whl"
|
||||
cp -rf "${PACKAGE_PATH}/dist"/*.whl "${PACKAGE_PATH}/${PACKAGE_NEW_NAME}"
|
||||
cp -f "${PACKAGE_PATH}/${PACKAGE_NEW_NAME}" "${OUTPUT_PATH}"
|
||||
find ${OUTPUT_PATH} -name "*.whl" -print0 | xargs -0 -I {} sh -c "sha256sum {} | awk '{printf \$1}' > {}.sha256"
|
||||
|
||||
cd "${BASEPATH}"
|
||||
|
||||
echo "------Successfully created mindspore package------"
|
Loading…
Reference in new issue