Skip to content

Commit f7e7712

Browse files
author
rocky Cloud User
committed
Handle setup-env Python versions
1 parent b4296d7 commit f7e7712

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

dev/setup-env.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,33 @@
22

33
set -euo pipefail
44

5+
if [[ -f /etc/os-release ]]; then
6+
. /etc/os-release
7+
OS=$ID
8+
VERSION_ID=$VERSION_ID
9+
else
10+
exit 1
11+
fi
12+
13+
MAJOR_VERSION=$(echo $VERSION_ID | cut -d. -f1)
14+
15+
PYTHON_VERSION=""
16+
17+
if [[ "$OS" == "ubuntu" && "$MAJOR_VERSION" == "22" ]]; then
18+
PYTHON_VERSION="/usr/bin/python3.10"
19+
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "8" ]]; then
20+
PYTHON_VERSION="/usr/bin/python3.8" # use `sudo yum install python38` on Rocky Linux 8 to install this
21+
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "9" ]]; then
22+
PYTHON_VERSION="/usr/bin/python3.9"
23+
else
24+
echo "Unsupported OS version: $OS $MAJOR_VERSION"
25+
exit 1
26+
fi
27+
528
if [[ ! -d "venv" ]]; then
6-
/usr/bin/python3.9 -m venv venv # use `sudo yum install python38` on Rocky Linux 8 to install this
29+
$PYTHON_VERSION -m venv venv
730
fi
31+
832
. venv/bin/activate
933
pip install -U pip
1034
pip install -r requirements.txt

0 commit comments

Comments
 (0)