From 956eff60ce126f31aba23f0b47f1ab645ea68506 Mon Sep 17 00:00:00 2001 From: "Hao, Ruomeng" Date: Fri, 1 Mar 2024 11:06:52 +0800 Subject: [PATCH] Update setupenv.sh Use python virtualenv to avoid PEP 668 Signed-off-by: Hao, Ruomeng --- setupenv.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/setupenv.sh b/setupenv.sh index 561b78c..744d343 100644 --- a/setupenv.sh +++ b/setupenv.sh @@ -2,7 +2,21 @@ CURR_DIR=$(pwd) -# setup PYTHONPATH -python3 -m pip install pip -U -python3 -m pip install "cctrusted_base @ git+https://github.com/cc-api/cc-trusted-api.git#subdirectory=common/python" -export PYTHONPATH=$PYTHONPATH:$CURR_DIR/src/python +# setup virtualenv and PYTHONPATH +apt-get install -y python3-virtualenv + +if [[ ! -d ${CURR_DIR}/venv ]]; then + python3 -m virtualenv -p python3 ${CURR_DIR}/venv + source ${CURR_DIR}/venv/bin/activate + python3 -m pip install "cctrusted_base @ git+https://github.com/cc-api/cc-trusted-api.git#subdirectory=common/python" + python3 -m pip install -r $CURR_DIR/src/python/requirements.txt + export PYTHONPATH=$PYTHONPATH:$CURR_DIR/src/python + if [ ! $? -eq 0 ]; then + echo "Failed to install python PIP packages, please check your proxy (https_proxy) or setup PyPi mirror." + deactivate + rm ${CURR_DIR}/venv -fr + return 1 + fi +else + source ${CURR_DIR}/venv/bin/activate +fi