1#!/bin/bash 2# Copyright 2022 Huawei Technologies Co., Ltd 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# confirm installed python3/pip 17which python || (echo "[ERROR] Please install 'python' first" && return 1) 18if [ $? -eq "1" ]; then 19 exit 1 20fi 21available_py_version=(3.7 3.8 3.9) 22PYTHON_VERSION=$(python --version | awk -F' ' '{print $2}') 23if [[ $PYTHON_VERSION == "" ]]; then 24 echo "python version is 2.x, but available versions are [${available_py_version[*]}]." 25 exit 1 26fi 27PYTHON_VERSION=${PYTHON_VERSION:0:3} 28if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then 29 echo "python version is '$PYTHON_VERSION', but available versions are [${available_py_version[*]}]." 30 exit 1 31fi 32which pip || (echo "[ERROR] Please install 'pip' first" && return 1) 33if [ $? -eq "1" ]; then 34 exit 1 35fi 36# cmakelint 37echo "[INFO] prepare to install cmakelint" 38pip install --upgrade --force-reinstall cmakelint 39# codespell 40echo "[INFO] prepare to install codespell" 41pip install --upgrade --force-reinstall codespell 42# cpplint 43echo "[INFO] prepare to install cpplint" 44pip install --upgrade --force-reinstall cpplint 45# lizard 46echo "[INFO] prepare to install lizard" 47pip install --upgrade --force-reinstall lizard 48# pylint 49echo "[INFO] prepare to install pylint" 50pip install pylint==2.3.1 51# check version 52echo "[INFO] check cmakelint version" 53cmakelint --version || echo "[WARMING] cmakelint not installed!" 54echo "[INFO] check codespell version" 55codespell --version || echo "[WARMING] codespell not installed!" 56echo "[INFO] check cpplint version" 57cpplint --version || echo "[WARMING] cpplint not installed!" 58echo "[INFO] check lizard version" 59lizard --version || echo "[WARMING] lizard not installed!" 60echo "[INFO] check pylint version" 61pylint --version || echo "[WARMING] pylint not installed!" 62