@@ -14,11 +14,41 @@ if (( $EUID != 0 )); then
14
14
SUDO=' sudo'
15
15
fi
16
16
17
+ # Function to check if a version of Python >= 3.10 is installed
18
+ check_python_version () {
19
+ if command -v python3 & > /dev/null; then
20
+ # Get the version of Python
21
+ PYTHON_VERSION=$( python3 --version | awk ' {print $2}' )
22
+ IFS=' .' read -r -a version_parts <<< " $PYTHON_VERSION"
23
+ echo " Python version: ${version_parts[0]} .${version_parts[1]} "
24
+ # >= 3.10
25
+ if (( ${version_parts[0]} >= 3 && ${version_parts[1]} >= 10 )) ; then
26
+ return 0
27
+ fi
28
+ fi
29
+ return 1
30
+ }
31
+
17
32
if [[ " $OSTYPE " == " darwin" * ]]; then
18
33
CPUS=$( sysctl -n hw.ncpu)
19
34
# ensure development environment is set correctly for clang
20
35
$SUDO xcode-select -switch /Library/Developer/CommandLineTools
21
- brew install llvm@14 googletest google-benchmark lcov make wget cmake curl
36
+ # see if homebrew is installed and install if not
37
+ if ! [[ -f /opt/homebrew/bin/brew ]]; then
38
+ echo -e " ${green} Installing Homebrew...${end} "
39
+ /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
40
+ fi
41
+ export PATH=" /opt/homebrew/bin:$PATH "
42
+
43
+ brew install llvm@14 googletest google-benchmark lcov make wget cmake curl bash python3 pylint python-matplotlib
44
+ brew upgrade bash
45
+
46
+ # Add Python 3 to PATH
47
+ echo " export PATH=\" /opt/homebrew/opt/python@3/bin:\$ PATH\" " >> ~ /.bash_profile
48
+ # Make python3 default
49
+ echo " alias python=python3" >> ~ /.bash_profile
50
+ . ~ /.bash_profile
51
+
22
52
CLANG_TIDY=/usr/local/bin/clang-tidy
23
53
if [ ! -L " $CLANG_TIDY " ]; then
24
54
$SUDO ln -s $( brew --prefix) /opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy
@@ -27,9 +57,8 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
27
57
if [ ! -L " $GMAKE " ]; then
28
58
$SUDO ln -s $( xcode-select -p) /usr/bin/gnumake /usr/local/bin/gmake
29
59
fi
30
- fi
31
60
32
- if [[ " $OSTYPE " == " linux-gnu" * ]]; then
61
+ elif [[ " $OSTYPE " == " linux-gnu" * ]]; then
33
62
$SUDO apt update
34
63
$SUDO apt install -y build-essential wget cmake libgtest-dev libbenchmark-dev lcov git software-properties-common rsync unzip
35
64
@@ -38,7 +67,20 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
38
67
$SUDO apt install -y clang-format-14 clang-tidy-14
39
68
$SUDO ln -s -f $( which clang-format-14) /usr/local/bin/clang-format
40
69
$SUDO ln -s -f $( which clang-tidy-14) /usr/local/bin/clang-tidy
70
+
71
+ # Python 3.10+ not installed so get the latest version
72
+ if ! check_python_version; then
73
+ $SUDO add-apt-repository ppa:deadsnakes/ppa
74
+ $SUDO apt update
75
+
76
+ latest_python_version=$( apt-cache search python3. | grep -o ' python3\.[0-9]*' | sort -V | tail -n 1)
77
+ $SUDO apt install -y $latest_python_version
78
+
79
+ $SUDO update-alternatives --install /usr/bin/python3 python3 /usr/bin/$( ls /usr/bin/ | grep -E ' ^python3\.[0-9]+$' | sort -V | tail -n 1) 1
80
+ $SUDO update-alternatives --config python3
81
+ fi
41
82
fi
83
+ python3 --version
42
84
43
85
PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py
44
86
if [ ! -f " ${PYTHON_TIDY} " ]; then
0 commit comments