From 23eb0841e866a92f8e16c164fc2a581df9c686c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Tarot=20=28=40silopolis=29?= Date: Thu, 28 Dec 2023 17:03:28 +0100 Subject: [PATCH] scripts: Test if venv is already activated --- scripts/bootstrap.sh | 8 +++++--- scripts/python_setup.sh | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 78fc608..967a3bb 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -17,9 +17,11 @@ echo "-- Shell: Source profile in case it's been updated" # shellcheck source="$HOME/.profile" disable=SC1091 source "$HOME/.profile" -echo "-- Activate Python virtual environment" -# shellcheck source="../.venv/bin/activate" -source .venv/bin/activate +if [[ ! $(pip -V) =~ .*\.venv.* ]]; then + echo "-- Python: Activate '.venv' virtual environment" + # shellcheck source="../.venv/bin/activate" disable=SC1091 + source .venv/bin/activate +fi echo "-- Install project Python requirements in venv" pip install -r requirements.txt diff --git a/scripts/python_setup.sh b/scripts/python_setup.sh index 4ce5926..04dd888 100755 --- a/scripts/python_setup.sh +++ b/scripts/python_setup.sh @@ -23,9 +23,11 @@ if [ ! -d .venv ]; then python3 -m venv .venv fi -echo "-- Python: Activate '.venv' virtual environment" -# shellcheck source="../.venv/bin/activate" -source .venv/bin/activate +if [[ ! $(pip -V) =~ .*\.venv.* ]]; then + echo "-- Python: Activate '.venv' virtual environment" + # shellcheck source="../.venv/bin/activate" disable=SC1091 + source .venv/bin/activate +fi echo "-- Upgrage Python pip and setuptools in venv" pip install --upgrade setuptools pip