diff --git a/Tools/export.sh b/Tools/export.sh index 602bc4423a..82a7384dff 100755 --- a/Tools/export.sh +++ b/Tools/export.sh @@ -32,6 +32,11 @@ fi # Common export PYTHON=${PYTHON:=$(which python3)} +# Python Virtual Environment +if [ -f ~/.venvs/Sming/bin/activate ]; then + source ~/.venvs/Sming/bin/activate +fi + # Esp8266 export ESP_HOME=${ESP_HOME:=/opt/esp-quick-toolchain} diff --git a/Tools/install.sh b/Tools/install.sh index f43d0cd56b..24fea7f0be 100755 --- a/Tools/install.sh +++ b/Tools/install.sh @@ -125,6 +125,15 @@ check_for_installed_files() { fi } +install_venv() { + echo + echo "!!! Trying to install Python Virtual Environment !!!" + mkdir -p ~/.venvs/ + python3 -m venv ~/.venvs/Sming + source ~/.venvs/Sming/bin/activate + eval "$1" +} + # Installers put downloaded archives here DOWNLOADS="downloads" mkdir -p $DOWNLOADS @@ -243,7 +252,9 @@ if [ -f "/usr/bin/clang-format-8" ]; then sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-8 100 fi -python3 -m pip install --upgrade pip protobuf -r "$SMING_HOME/../Tools/requirements.txt" +PYTHON_INSTALL_CMD="python3 -m pip install --upgrade pip protobuf -r \"$SMING_HOME/../Tools/requirements.txt\"" + +eval $PYTHON_INSTALL_CMD || install_venv "$PYTHON_INSTALL_CMD" install() {