diff --git a/.gitignore b/.gitignore index ce1524cf..7472ff3c 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,4 @@ output/ !output/README.md mindinsight/ui/public/static/js/graphvizlib.wasm +third_party/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ef38fee..131d3605 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.14) +project(MindInsight) + find_package(Git QUIET) 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) #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) aux_source_directory(./third_party/securec/src SECUREC_SRCS) diff --git a/MANIFEST.in b/MANIFEST.in index 4eae89e8..177947ba 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,5 +3,6 @@ recursive-exclude * .git recursive-exclude * .gitignore recursive-exclude * __pycache__ recursive-exclude * *.py[co] *.swp +recursive-exclude mindinsight/datavisual/utils/crc32 * recursive-exclude mindinsight/ui * recursive-include mindinsight/ui/dist * diff --git a/build/build.sh b/build/build.sh index d5ddb745..69c6c7d9 100755 --- a/build/build.sh +++ b/build/build.sh @@ -24,13 +24,10 @@ rename_wheel() { VERSION="$("$PYTHON" -c 'import platform; print(platform.python_version())')" PACKAGE_LIST=$(ls mindinsight-*-any.whl) || exit 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_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)" PACKAGE_NEW="mindinsight-$MINDINSIGHT_VERSION-$PYTHON_VERSION_TAG-$PYTHON_ABI_TAG-$MACHINE_TAG.whl" mv "$PACKAGE_ORIG" "$PACKAGE_NEW" @@ -63,15 +60,15 @@ build_wheel() { echo "start building mindinsight" clean_files - if command -v python3; then + if command -v python3 > /dev/null; then PYTHON=python3 - elif command -v python; then + elif command -v python > /dev/null; then PYTHON=python else command python3 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)" exit 1 fi diff --git a/build/scripts/crc32.sh b/build/scripts/crc32.sh index 6cecd5a3..bcfcec71 100755 --- a/build/scripts/crc32.sh +++ b/build/scripts/crc32.sh @@ -17,74 +17,62 @@ set -e 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 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++ fi - if command -v python3; then + if command -v python3 > /dev/null; then PYTHON=python3 - elif command -v python; then + elif command -v python > /dev/null; then PYTHON=python else command python3 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)" exit 1 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" exit 1 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 \ -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 echo "$CRC32_SO_FILE file does not exist, build failed" exit 1 fi - mv "$CRC32_SO_FILE" "$CRC32_OUTPUT_DIR" + [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR" } -build_securec - build_crc32 - -clean_securec diff --git a/build/scripts/ui.sh b/build/scripts/ui.sh index 4a2173b7..b09af33c 100755 --- a/build/scripts/ui.sh +++ b/build/scripts/ui.sh @@ -20,7 +20,7 @@ SCRIPT_BASEDIR=$(realpath "$(dirname "$0")") build_ui() { cd "$(realpath "$SCRIPT_BASEDIR/../../mindinsight/ui")" || exit - if ! command -v npm; then + if ! command -v npm > /dev/null; then command npm fi diff --git a/mindinsight/ui/package.json b/mindinsight/ui/package.json index be70fa39..db2a67c2 100644 --- a/mindinsight/ui/package.json +++ b/mindinsight/ui/package.json @@ -13,14 +13,14 @@ "core-js": "3.6.5", "d3": "5.9.7", "d3-graphviz": "3.0.4", + "echarts": "4.7.0", "element-ui": "2.13.0", "jquery": "3.5.0", "slickgrid": "2.4.22", "vue": "2.6.11", "vue-i18n": "8.15.0", "vue-router": "3.1.3", - "vuex": "3.1.1", - "echarts": "4.7.0" + "vuex": "3.1.1" }, "devDependencies": { "@intlify/vue-i18n-loader": "0.6.1", diff --git a/mindinsight/utils/hook.py b/mindinsight/utils/hook.py index 319ae331..714f63a8 100644 --- a/mindinsight/utils/hook.py +++ b/mindinsight/utils/hook.py @@ -87,7 +87,7 @@ class HookUtils: """Discover hook instances.""" self.__hooks = [] 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.sort() for file in files: diff --git a/setup.py b/setup.py index c5bf4431..acc0cd3f 100644 --- a/setup.py +++ b/setup.py @@ -37,10 +37,11 @@ def get_version(): str, mindinsight version. """ 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__' + 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) return version_module.VERSION