-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.sh
executable file
·45 lines (38 loc) · 1.3 KB
/
activate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
#
# "Set-ups or/and activates development environment"
#
VENV_FOLDER=".venv"
PRIMARY_PYTHON_VERSION="3.12" # sync with .github/workflows/ci.yml
RED='\033[1;31m'
GREEN='\033[1;32m'
CYAN='\033[1;36m'
NC='\033[0m' # No Color
if ! (return 0 2>/dev/null) ; then
# If return is used in the top-level scope of a non-sourced script,
# an error message is emitted, and the exit code is set to 1
echo
echo -e $RED"This script should be sourced like"$NC
echo " . ./activate.sh"
echo
exit 1
fi
# virtual env
if [[ ! -d ${VENV_FOLDER} ]] ; then
unset CONDA_PREFIX # if conda is installed, it will mess with the virtual env
echo -e $CYAN"Creating virtual environment for python in ${VENV_FOLDER}"$NC
if uv venv ${VENV_FOLDER} --python=python${PRIMARY_PYTHON_VERSION}; then
START_TIME=$(date +%s)
. ${VENV_FOLDER}/bin/activate
uv pip install --upgrade pip
uv pip install -r requirements.dev.txt
END_TIME=$(date +%s)
echo "Environment created in $((END_TIME - $START_TIME)) seconds"
else
echo -e $RED"Error to create virtual env. Do you have Astral's UV installed ( https://github.com/astral-sh/uv )?"$NC
return 1
fi
else
echo -e $CYAN"Activating virtual environment ..."$NC
. ${VENV_FOLDER}/bin/activate
fi