Skip to content

Commit 7323f53

Browse files
committed
Added python 3.10+ install to build flow with necessary packages
Signed-off-by: Morgan Rockett <[email protected]>
1 parent 7e17ecb commit 7323f53

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
timeout-minutes: 5
5454
strategy:
5555
matrix:
56-
python-version: ["3.10"]
56+
python-version: ["3.10", "3.11", "3.12"]
5757
steps:
5858
- uses: actions/checkout@v2
5959
with:
@@ -64,7 +64,7 @@ jobs:
6464
python-version: ${{ matrix.python-version }}
6565
- name: Install dependencies
6666
run: |
67-
python -m pip install --upgrade pip
67+
python3 -m pip install --upgrade pip
6868
if [ -f requirements_py.txt ]; then pip install -r requirements_py.txt; fi
6969
pip install pylint
7070
- name: Lint with Pylint

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CMakeCache.txt
3737
*.o-*
3838
*.a
3939
*.log
40+
*.tgz
4041

4142
leveldb*/
4243
NuRaft*/
@@ -46,6 +47,7 @@ ethash*/
4647
lua-*/
4748
benchmark-results/
4849
CMakeFiles/
50+
Python-*/
4951
plots/
5052
.deps/
5153
.libs/
@@ -54,7 +56,6 @@ plots/
5456
blocks.dat
5557
test_db
5658

57-
5859
# System files
5960
.DS_Store
6061
.dirstamp
@@ -72,3 +73,4 @@ build/tests
7273

7374
# E2E Test results
7475
testruns/
76+

scripts/install-build-tools.sh

+45-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,41 @@ if (( $EUID != 0 )); then
1414
SUDO='sudo'
1515
fi
1616

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+
1732
if [[ "$OSTYPE" == "darwin"* ]]; then
1833
CPUS=$(sysctl -n hw.ncpu)
1934
# ensure development environment is set correctly for clang
2035
$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+
2252
CLANG_TIDY=/usr/local/bin/clang-tidy
2353
if [ ! -L "$CLANG_TIDY" ]; then
2454
$SUDO ln -s $(brew --prefix)/opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy
@@ -27,9 +57,8 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
2757
if [ ! -L "$GMAKE" ]; then
2858
$SUDO ln -s $(xcode-select -p)/usr/bin/gnumake /usr/local/bin/gmake
2959
fi
30-
fi
3160

32-
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
61+
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
3362
$SUDO apt update
3463
$SUDO apt install -y build-essential wget cmake libgtest-dev libbenchmark-dev lcov git software-properties-common rsync unzip
3564

@@ -38,7 +67,20 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
3867
$SUDO apt install -y clang-format-14 clang-tidy-14
3968
$SUDO ln -s -f $(which clang-format-14) /usr/local/bin/clang-format
4069
$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
4182
fi
83+
python3 --version
4284

4385
PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py
4486
if [ ! -f "${PYTHON_TIDY}" ]; then

scripts/setup-dependencies.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ end="\033[0m"
99
set -e
1010

1111
# install in a custom prefix rather than /usr/local. by default, this
12-
# chooses "prefix" directory alongside "scripts" where configure.sh
13-
# resides.
12+
# chooses "prefix" directory alongside "scripts" directory.
1413

1514
PREFIX="$(cd "$(dirname "$0")"/.. && pwd)/prefix"
1615
echo "Will install local dependencies in the following prefix: $PREFIX"

0 commit comments

Comments
 (0)