From: @liangyongxiong1024 Reviewed-by: Signed-off-by:tags/v1.2.0-rc1
| @@ -92,3 +92,4 @@ output/ | |||||
| !output/README.md | !output/README.md | ||||
| mindinsight/ui/public/static/js/graphvizlib.wasm | mindinsight/ui/public/static/js/graphvizlib.wasm | ||||
| third_party/* | |||||
| @@ -1,5 +1,7 @@ | |||||
| cmake_minimum_required(VERSION 3.14) | cmake_minimum_required(VERSION 3.14) | ||||
| project(MindInsight) | |||||
| find_package(Git QUIET) | find_package(Git QUIET) | ||||
| if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") | if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") | ||||
| @@ -30,7 +32,7 @@ set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -fvisibility=hidden -Wno | |||||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||||
| #add flags | #add flags | ||||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror") | |||||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") | |||||
| include_directories(./third_party/securec/include) | include_directories(./third_party/securec/include) | ||||
| aux_source_directory(./third_party/securec/src SECUREC_SRCS) | aux_source_directory(./third_party/securec/src SECUREC_SRCS) | ||||
| @@ -3,5 +3,6 @@ recursive-exclude * .git | |||||
| recursive-exclude * .gitignore | recursive-exclude * .gitignore | ||||
| recursive-exclude * __pycache__ | recursive-exclude * __pycache__ | ||||
| recursive-exclude * *.py[co] *.swp | recursive-exclude * *.py[co] *.swp | ||||
| recursive-exclude mindinsight/datavisual/utils/crc32 * | |||||
| recursive-exclude mindinsight/ui * | recursive-exclude mindinsight/ui * | ||||
| recursive-include mindinsight/ui/dist * | recursive-include mindinsight/ui/dist * | ||||
| @@ -24,13 +24,10 @@ rename_wheel() { | |||||
| VERSION="$("$PYTHON" -c 'import platform; print(platform.python_version())')" | VERSION="$("$PYTHON" -c 'import platform; print(platform.python_version())')" | ||||
| PACKAGE_LIST=$(ls mindinsight-*-any.whl) || exit | PACKAGE_LIST=$(ls mindinsight-*-any.whl) || exit | ||||
| for PACKAGE_ORIG in $PACKAGE_LIST; do | for PACKAGE_ORIG in $PACKAGE_LIST; do | ||||
| MINDINSIGHT_VERSION=$(echo "$PACKAGE_ORIG" | awk -F"-" '{print $2}') | |||||
| PYTHON_VERSION_NUM=$(echo "$VERSION" | awk -F"." '{print $1$2}') | |||||
| MINDINSIGHT_VERSION=$(echo "$PACKAGE_ORIG" | awk -F'-' '{print $2}') | |||||
| PYTHON_VERSION_NUM=$(echo "$VERSION" | awk -F'.' '{print $1$2}') | |||||
| PYTHON_VERSION_TAG="cp$PYTHON_VERSION_NUM" | PYTHON_VERSION_TAG="cp$PYTHON_VERSION_NUM" | ||||
| PYTHON_ABI_TAG="cp${PYTHON_VERSION_NUM}" | |||||
| if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 8)' &>/dev/null; then | |||||
| PYTHON_ABI_TAG="${PYTHON_ABI_TAG}m" | |||||
| fi | |||||
| PYTHON_ABI_TAG="cp$(python3-config --extension-suffix | awk -F'-' '{print $2}')" | |||||
| MACHINE_TAG="$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m)" | MACHINE_TAG="$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m)" | ||||
| PACKAGE_NEW="mindinsight-$MINDINSIGHT_VERSION-$PYTHON_VERSION_TAG-$PYTHON_ABI_TAG-$MACHINE_TAG.whl" | PACKAGE_NEW="mindinsight-$MINDINSIGHT_VERSION-$PYTHON_VERSION_TAG-$PYTHON_ABI_TAG-$MACHINE_TAG.whl" | ||||
| mv "$PACKAGE_ORIG" "$PACKAGE_NEW" | mv "$PACKAGE_ORIG" "$PACKAGE_NEW" | ||||
| @@ -63,15 +60,15 @@ build_wheel() { | |||||
| echo "start building mindinsight" | echo "start building mindinsight" | ||||
| clean_files | clean_files | ||||
| if command -v python3; then | |||||
| if command -v python3 > /dev/null; then | |||||
| PYTHON=python3 | PYTHON=python3 | ||||
| elif command -v python; then | |||||
| elif command -v python > /dev/null; then | |||||
| PYTHON=python | PYTHON=python | ||||
| else | else | ||||
| command python3 | command python3 | ||||
| fi | fi | ||||
| if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 7)' &>/dev/null; then | |||||
| if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 7)' > /dev/null; then | |||||
| echo "Python 3.7 or higher is required. You are running $("$PYTHON" -V)" | echo "Python 3.7 or higher is required. You are running $("$PYTHON" -V)" | ||||
| exit 1 | exit 1 | ||||
| fi | fi | ||||
| @@ -17,74 +17,62 @@ set -e | |||||
| SCRIPT_BASEDIR=$(realpath "$(dirname "$0")") | SCRIPT_BASEDIR=$(realpath "$(dirname "$0")") | ||||
| THIRD_PARTY_DIR=$(realpath "$SCRIPT_BASEDIR/../../third_party") | |||||
| MINDINSIGHT_DIR=$(realpath "$SCRIPT_BASEDIR/../../mindinsight") | |||||
| BUILDDIR="$(dirname "$SCRIPT_BASEDIR")/build_securec" | |||||
| build_securec() { | |||||
| [ -n "$BUILDDIR" ] && rm -rf "$BUILDDIR" | |||||
| mkdir "$BUILDDIR" | |||||
| cd "$BUILDDIR" || exit | |||||
| if ! command -v cmake; then | |||||
| build_crc32() { | |||||
| if ! command -v cmake > /dev/null; then | |||||
| command cmake | command cmake | ||||
| fi | fi | ||||
| cmake ../.. | |||||
| make | |||||
| } | |||||
| clean_securec() { | |||||
| [ -n "$BUILDDIR" ] && rm -rf "$BUILDDIR" | |||||
| } | |||||
| build_crc32() { | |||||
| DATAVISUAL_DIR=$(realpath "$SCRIPT_BASEDIR/../../mindinsight/datavisual") | |||||
| CRC32_SOURCE_DIR="$DATAVISUAL_DIR/utils/crc32" | |||||
| CRC32_OUTPUT_DIR="$DATAVISUAL_DIR/utils" | |||||
| CRC32_SO_FILE="crc32$(python3-config --extension-suffix)" | |||||
| cd "$CRC32_SOURCE_DIR" || exit | |||||
| if ! command -v c++; then | |||||
| if ! command -v c++ > /dev/null; then | |||||
| command c++ | command c++ | ||||
| fi | fi | ||||
| if command -v python3; then | |||||
| if command -v python3 > /dev/null; then | |||||
| PYTHON=python3 | PYTHON=python3 | ||||
| elif command -v python; then | |||||
| elif command -v python > /dev/null; then | |||||
| PYTHON=python | PYTHON=python | ||||
| else | else | ||||
| command python3 | command python3 | ||||
| fi | fi | ||||
| if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 7)' &>/dev/null; then | |||||
| if ! "$PYTHON" -c 'import sys; assert sys.version_info >= (3, 7)' > /dev/null; then | |||||
| echo "Python 3.7 or higher is required. You are running $("$PYTHON" -V)" | echo "Python 3.7 or higher is required. You are running $("$PYTHON" -V)" | ||||
| exit 1 | exit 1 | ||||
| fi | fi | ||||
| rm -f "$CRC32_SOURCE_DIR/$CRC32_SO_FILE" | |||||
| rm -f "$CRC32_OUTPUT_DIR/$CRC32_SO_FILE" | |||||
| read -ra PYBIND11_INCLUDES <<< "$($PYTHON -m pybind11 --includes)" | |||||
| if [ ! -n "${PYBIND11_INCLUDES[0]}" ]; then | |||||
| PYBIND11_INCLUDES="$($PYTHON -m pybind11 --includes)" | |||||
| if [ ! -n "$PYBIND11_INCLUDES" ]; then | |||||
| echo "pybind11 is required" | echo "pybind11 is required" | ||||
| exit 1 | exit 1 | ||||
| fi | fi | ||||
| BUILDDIR="$(dirname "$SCRIPT_BASEDIR")/build_securec" | |||||
| [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR" | |||||
| mkdir "$BUILDDIR" | |||||
| cd "$BUILDDIR" || exit | |||||
| cmake ../.. | |||||
| cmake --build . | |||||
| MINDINSIGHT_DIR=$(realpath "$SCRIPT_BASEDIR/../../mindinsight") | |||||
| THIRD_PARTY_DIR=$(realpath "$SCRIPT_BASEDIR/../../third_party") | |||||
| cd "$MINDINSIGHT_DIR/datavisual/utils" || exit | |||||
| CRC32_SO_FILE="crc32$(python3-config --extension-suffix)" | |||||
| rm -f "$CRC32_SO_FILE" | |||||
| SECUREC_LIB_FILE="$BUILDDIR/libsecurec.a" | |||||
| c++ -O2 -O3 -shared -std=c++11 -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 \ | c++ -O2 -O3 -shared -std=c++11 -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 \ | ||||
| -Wno-maybe-uninitialized -Wno-unused-parameter -Wall -Wl,-z,relro,-z,now,-z,noexecstack \ | -Wno-maybe-uninitialized -Wno-unused-parameter -Wall -Wl,-z,relro,-z,now,-z,noexecstack \ | ||||
| -I"$MINDINSIGHT_DIR" -I"$THIRD_PARTY_DIR" "${PYBIND11_INCLUDES[0]}" "${PYBIND11_INCLUDES[1]}" \ | |||||
| -o "$CRC32_SO_FILE" crc32.cc "$BUILDDIR/libsecurec.a" | |||||
| -I"$MINDINSIGHT_DIR" -I"$THIRD_PARTY_DIR" $PYBIND11_INCLUDES \ | |||||
| -o "$CRC32_SO_FILE" crc32/crc32.cc "$SECUREC_LIB_FILE" | |||||
| if [ ! -f "$CRC32_SO_FILE" ]; then | if [ ! -f "$CRC32_SO_FILE" ]; then | ||||
| echo "$CRC32_SO_FILE file does not exist, build failed" | echo "$CRC32_SO_FILE file does not exist, build failed" | ||||
| exit 1 | exit 1 | ||||
| fi | fi | ||||
| mv "$CRC32_SO_FILE" "$CRC32_OUTPUT_DIR" | |||||
| [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR" | |||||
| } | } | ||||
| build_securec | |||||
| build_crc32 | build_crc32 | ||||
| clean_securec | |||||
| @@ -20,7 +20,7 @@ SCRIPT_BASEDIR=$(realpath "$(dirname "$0")") | |||||
| build_ui() { | build_ui() { | ||||
| cd "$(realpath "$SCRIPT_BASEDIR/../../mindinsight/ui")" || exit | cd "$(realpath "$SCRIPT_BASEDIR/../../mindinsight/ui")" || exit | ||||
| if ! command -v npm; then | |||||
| if ! command -v npm > /dev/null; then | |||||
| command npm | command npm | ||||
| fi | fi | ||||
| @@ -13,14 +13,14 @@ | |||||
| "core-js": "3.6.5", | "core-js": "3.6.5", | ||||
| "d3": "5.9.7", | "d3": "5.9.7", | ||||
| "d3-graphviz": "3.0.4", | "d3-graphviz": "3.0.4", | ||||
| "echarts": "4.7.0", | |||||
| "element-ui": "2.13.0", | "element-ui": "2.13.0", | ||||
| "jquery": "3.5.0", | "jquery": "3.5.0", | ||||
| "slickgrid": "2.4.22", | "slickgrid": "2.4.22", | ||||
| "vue": "2.6.11", | "vue": "2.6.11", | ||||
| "vue-i18n": "8.15.0", | "vue-i18n": "8.15.0", | ||||
| "vue-router": "3.1.3", | "vue-router": "3.1.3", | ||||
| "vuex": "3.1.1", | |||||
| "echarts": "4.7.0" | |||||
| "vuex": "3.1.1" | |||||
| }, | }, | ||||
| "devDependencies": { | "devDependencies": { | ||||
| "@intlify/vue-i18n-loader": "0.6.1", | "@intlify/vue-i18n-loader": "0.6.1", | ||||
| @@ -87,7 +87,7 @@ class HookUtils: | |||||
| """Discover hook instances.""" | """Discover hook instances.""" | ||||
| self.__hooks = [] | self.__hooks = [] | ||||
| mindinsight_path = os.path.join(__file__, os.pardir, os.pardir) | mindinsight_path = os.path.join(__file__, os.pardir, os.pardir) | ||||
| hook_path = os.path.realpath(os.path.join(mindinsight_path, 'common/hook')) | |||||
| hook_path = os.path.realpath(os.path.join(mindinsight_path, 'common', 'hook')) | |||||
| files = os.listdir(hook_path) | files = os.listdir(hook_path) | ||||
| files.sort() | files.sort() | ||||
| for file in files: | for file in files: | ||||
| @@ -37,10 +37,11 @@ def get_version(): | |||||
| str, mindinsight version. | str, mindinsight version. | ||||
| """ | """ | ||||
| machinery = import_module('importlib.machinery') | machinery = import_module('importlib.machinery') | ||||
| version_path = os.path.join(os.path.dirname(__file__), 'mindinsight', '_version.py') | |||||
| module_path = os.path.join(os.path.dirname(__file__), 'mindinsight', '_version.py') | |||||
| module_name = '__mindinsightversion__' | module_name = '__mindinsightversion__' | ||||
| version_module = types.ModuleType(module_name) | version_module = types.ModuleType(module_name) | ||||
| loader = machinery.SourceFileLoader(module_name, version_path) | |||||
| loader = machinery.SourceFileLoader(module_name, module_path) | |||||
| loader.exec_module(version_module) | loader.exec_module(version_module) | ||||
| return version_module.VERSION | return version_module.VERSION | ||||