forked from microsoft/CyberBattleSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetpythonpath.sh
More file actions
37 lines (29 loc) · 839 Bytes
/
getpythonpath.sh
File metadata and controls
37 lines (29 loc) · 839 Bytes
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
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Look for the the required version of python, return its path in $PYTHON
# and version in $PYTHONVER.
#
# Usage: source this file to set the correct default version of Python in the PATH:
# source getpythonpath.sh
#
PYTHON=`which python`
if [ -z "$PYTHON" ]; then
PYTHON=`which python3`
fi
if [ -z "$PYTHON" ]; then
PYTHON=`which python3.9`
fi
if [ -z "$PYTHON" ]; then
echo "Could not located python interpreter: '$PYTHON'" >&2
exit -1
fi
PYTHONVER=`$PYTHON --version | cut -d' ' -f2`
if [[ ! "$PYTHONVER" == "3.9."* ]]; then
echo 'Version ~=3.9 of Python is required' >&2
exit
else
echo "Compatible version $PYTHONVER of Python detected at $PYTHON"
fi
PYTHONPATH=$(dirname $PYTHON)
export PATH=$PYTHONPATH:$PATH