Skip to content

Commit 2de4f84

Browse files
authored
Merge pull request #588 from stackhpc/setup-env-python-version
Support setting PYTHON_VERSION
2 parents 0e54e7e + 5db768a commit 2de4f84

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

dev/setup-env.sh

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22

33
set -euo pipefail
44

5-
if [[ -f /etc/os-release ]]; then
6-
. /etc/os-release
7-
OS=$ID
8-
OS_VERSION=$VERSION_ID
9-
else
10-
exit 1
11-
fi
5+
PYTHON_VERSION=${PYTHON_VERSION:-}
126

13-
MAJOR_VERSION=$(echo $OS_VERSION | cut -d. -f1)
7+
if [[ "$PYTHON_VERSION" == "" ]]; then
8+
if [[ -f /etc/os-release ]]; then
9+
. /etc/os-release
10+
OS=$ID
11+
OS_VERSION=$VERSION_ID
12+
else
13+
exit 1
14+
fi
1415

15-
PYTHON_VERSION=""
16+
MAJOR_VERSION=$(echo $OS_VERSION | cut -d. -f1)
1617

17-
if [[ "$OS" == "ubuntu" && "$MAJOR_VERSION" == "22" ]]; then
18-
PYTHON_VERSION="/usr/bin/python3.10"
19-
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "8" ]]; then
20-
# python3.9+ doesn't have selinux bindings
21-
PYTHON_VERSION="/usr/bin/python3.8" # use `sudo yum install python38` on Rocky Linux 8 to install this
22-
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "9" ]]; then
23-
PYTHON_VERSION="/usr/bin/python3.9"
24-
else
25-
echo "Unsupported OS version: $OS $MAJOR_VERSION"
26-
exit 1
18+
if [[ "$OS" == "ubuntu" && "$MAJOR_VERSION" == "22" ]]; then
19+
PYTHON_VERSION="/usr/bin/python3.10"
20+
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "8" ]]; then
21+
# python3.9+ doesn't have selinux bindings
22+
PYTHON_VERSION="/usr/bin/python3.8" # use `sudo yum install python38` on Rocky Linux 8 to install this
23+
elif [[ "$OS" == "rocky" && "$MAJOR_VERSION" == "9" ]]; then
24+
PYTHON_VERSION="/usr/bin/python3.9"
25+
else
26+
echo "Unsupported OS version: $OS $MAJOR_VERSION"
27+
exit 1
28+
fi
2729
fi
2830

2931
if [[ ! -d "venv" ]]; then

0 commit comments

Comments
 (0)