diff --git a/build.sh b/build.sh index fa76d1ff51c5d85814a1e3f3c57d80637bd0a8fc..e32a92a765e7ede2897d71b635420c4e0b689c22 100644 --- a/build.sh +++ b/build.sh @@ -8,12 +8,25 @@ BUILD_DIR=$TOP_DIR/build mkdir -p $BUILD_DIR +check_duplicated() { + filename_format=$1 + file_num=`ls dist/${filename_format} | wc -l | awk '{$1=$1;print}'` + if [ "$file_num" != "1" ]; then + echo "dist have duplicate file for $file_num, please clean and rerun" + exit 1 + fi +} + build_frontend() { cd $FRONTEND_DIR if [ ! -d "dist" ]; then npm install npm run build fi + for file_name in "manifest.*.js" "index.*.js" "vendor.*.js"; do + echo $file_name + check_duplicated $file_name + done } build_frontend_fake() { @@ -43,6 +56,14 @@ build_onnx_graph() { protoc onnx.proto --python_out . } +clean_env() { + rm -rf $TOP_DIR/visualdl/server/dist + rm -rf $BUILD_DIR/bdist* + rm -rf $BUILD_DIR/lib* + rm -rf $BUILD_DIR/temp* + rm -rf $BUILD_DIR/scripts* +} + package() { cp -rf $FRONTEND_DIR/dist $TOP_DIR/visualdl/server/ cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl @@ -53,12 +74,13 @@ ARG=$1 echo "ARG: " $ARG -if [ $ARG = "travis-CI" ]; then +if [ "$ARG" = "travis-CI" ]; then build_frontend_fake else build_frontend fi +clean_env build_backend build_onnx_graph package diff --git a/setup.py b/setup.py index ad092fa4a6dac560846bbf939ad8b10564f963d8..e7fab52e63b33607b4800941c26fad5d70ede40f 100644 --- a/setup.py +++ b/setup.py @@ -76,14 +76,6 @@ packages = [ 'visualdl.server.onnx', ] -datas = [] -data_root = os.path.join(TOP_DIR, 'visualdl/server/dist') -for root, dirs, files in os.walk(data_root): - for filename in files: - path = 'dist/' + os.path.join(root, filename)[len(data_root) + 1:] - datas.append(path) -print datas - setup( name="visualdl", version=VERSION_NUMBER, @@ -94,7 +86,8 @@ setup( long_description=read('README.md'), install_requires=install_requires, package_data={ - 'visualdl.server': datas, + 'visualdl.server': + ['dist/*.js', 'dist/*.html', 'dist/fonts/*', 'dist/images/*'], 'visualdl': ['core.so'], 'visualdl.python': ['core.so', 'dog.jpg'] },