-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_pyenv.sh
More file actions
executable file
Β·55 lines (45 loc) Β· 2.72 KB
/
setup_pyenv.sh
File metadata and controls
executable file
Β·55 lines (45 loc) Β· 2.72 KB
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
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# ββ setup_pyenv.sh βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Creates a Python virtual-environment in .pyenv/ at the project root and
# installs the pip dependencies needed by the vendor/scripts/ tooling.
#
# Usage (from project root):
# bash vendor/scripts/setup_pyenv.sh # create & install
# source .pyenv/bin/activate # activate in current shell
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
VENV_DIR="$PROJECT_ROOT/.pyenv"
# ββ colors βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
GREEN='\033[92m'
CYAN='\033[96m'
DIM='\033[2m'
BOLD='\033[1m'
RESET='\033[0m'
info() { printf " ${DIM}β${RESET} %s\n" "$*"; }
ok() { printf " ${GREEN}β${RESET} ${BOLD}%s${RESET}\n" "$*"; }
# ββ create venv ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if [ -d "$VENV_DIR" ] && [ -f "$VENV_DIR/bin/python3" ]; then
info "venv already exists at ${CYAN}.pyenv/${RESET}"
else
info "creating venv at ${CYAN}.pyenv/${RESET}"
python3 -m venv "$VENV_DIR"
fi
# ββ activate βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
# ββ upgrade pip silently βββββββββββββββββββββββββββββββββββββββββββββββββββββ
info "upgrading pip"
pip install --upgrade pip --quiet 2>/dev/null
# ββ install dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββ
DEPS=(cpplint clang-format)
for dep in "${DEPS[@]}"; do
if pip show "$dep" > /dev/null 2>&1; then
info "$dep ${DIM}already installed${RESET}"
else
info "installing ${CYAN}$dep${RESET}"
pip install "$dep" --quiet
fi
done
ok "pyenv ready β source .pyenv/bin/activate"