-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_venv.sh
More file actions
39 lines (32 loc) · 1.18 KB
/
setup_venv.sh
File metadata and controls
39 lines (32 loc) · 1.18 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
#!/bin/bash
# (c) JFrog Ltd (2026).
# setup_venv.sh
# Find Python 3.11+ (check python3.11, python3.12, python3.13, etc., then fallback to python3)
PYTHON_CMD=""
for version in python3.11 python3.12 python3.13 python3.14 python3.15 python3; do
if command -v $version &> /dev/null; then
# Check if version is 3.11 or higher
VERSION_OUTPUT=$($version --version 2>&1)
VERSION_NUM=$(echo "$VERSION_OUTPUT" | grep -oE '[0-9]+\.[0-9]+' | head -1)
MAJOR=$(echo "$VERSION_NUM" | cut -d. -f1)
MINOR=$(echo "$VERSION_NUM" | cut -d. -f2)
if [ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 11 ]; then
PYTHON_CMD=$version
echo "Found Python $VERSION_NUM at: $(which $version)"
break
fi
fi
done
# Check if Python 3.11+ is available
if [ -z "$PYTHON_CMD" ]; then
echo "Python 3.11+ not found. Please install it first."
exit 1
fi
# Create virtual environment
$PYTHON_CMD -m venv .venv
# Activate and install dependencies
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
echo "Virtual environment created and dependencies installed!"
echo "To activate: source .venv/bin/activate"