• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2020-2021 Huawei Device Co., Ltd.
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
17set -e
18
19error()
20{
21  echo "$1"
22  exit 1
23}
24PYTHON="python3"
25TOOLS_DIR="tools"
26
27flag=$(command -v $PYTHON | grep -c $PYTHON)
28if [ "$flag" -eq 0 ]; then
29    error "Python3.7 or higher version required!"
30fi
31
32$PYTHON -c 'import sys; exit(1) if sys.version_info.major < 3 or sys.version_info.minor < 7 else exit(0)' || \
33error "Python3.7 or higher version required!"
34cd $(dirname "$0") || error "Failure to change direcory!"
35$PYTHON -c "import pip" || error "Please install pip first!"
36$PYTHON -c "import easy_install" || error "Please install setuptools first!"
37
38if [ ! -d "$TOOLS_DIR" ]; then
39  error "$TOOLS_DIR directory not exists"
40fi
41
42$PYTHON -m pip uninstall -y xdevice
43$PYTHON -m pip uninstall -y xdevice-extension
44$PYTHON -m pip uninstall -y xdevice-ohos
45
46for f in "$TOOLS_DIR"/*.egg
47do
48  if [ ! -e "$f" ]; then
49    error "Can not find xdevice package!"
50  fi
51  $PYTHON -m easy_install --user "$f" || echo "Error occurs to install $f!"
52done
53
54for f in "$TOOLS_DIR"/*.tar.gz
55do
56  if [ ! -e "$f" ]; then
57    error "Can not find xdevice package!"
58  fi
59  $PYTHON -m pip install --user "$f" || echo "Error occurs to install $f!"
60done
61
62$PYTHON -m xdevice "$@"
63exit 0
64