Skip to content

Commit

Permalink
Ubuntu 24.04 and later is not allowing the overwriting of system pyth…
Browse files Browse the repository at this point in the history
…on packages.

A proper fix will be to create virtual environment and activate it to avoid conflicts with the python packages coming from the OS.
  • Loading branch information
slav-at-attachix committed Oct 22, 2024
1 parent 360826a commit a501ada
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Tools/export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
13 changes: 12 additions & 1 deletion Tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit a501ada

Please sign in to comment.