Skip to content

Commit

Permalink
Added python 3.10 install to build flow with necessary packages
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Rockett <[email protected]>
  • Loading branch information
rockett-m committed Jun 13, 2024
1 parent 7e17ecb commit 3b9400a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.10+"]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -64,7 +64,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
if [ -f requirements_py.txt ]; then pip install -r requirements_py.txt; fi
pip install pylint
- name: Lint with Pylint
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CMakeCache.txt
*.o-*
*.a
*.log
*.tgz

leveldb*/
NuRaft*/
Expand All @@ -46,6 +47,7 @@ ethash*/
lua-*/
benchmark-results/
CMakeFiles/
Python-*/
plots/
.deps/
.libs/
Expand All @@ -54,7 +56,6 @@ plots/
blocks.dat
test_db


# System files
.DS_Store
.dirstamp
Expand All @@ -72,3 +73,4 @@ build/tests

# E2E Test results
testruns/

48 changes: 45 additions & 3 deletions scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,41 @@ if (( $EUID != 0 )); then
SUDO='sudo'
fi

# Function to check if a version of Python >= 3.10 is installed
check_python_version() {
if command -v python3 &>/dev/null; then
# Get the version of Python
PYTHON_VERSION=$(python3 --version | awk '{print $2}')
IFS='.' read -r -a version_parts <<< "$PYTHON_VERSION"
echo "Python version: ${version_parts[0]}.${version_parts[1]}"
# >= 3.10
if (( ${version_parts[0]} >= 3 && ${version_parts[1]} >= 10 )); then
return 0
fi
fi
return 1
}

if [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
# ensure development environment is set correctly for clang
$SUDO xcode-select -switch /Library/Developer/CommandLineTools
brew install llvm@14 googletest google-benchmark lcov make wget cmake curl
# see if homebrew is installed and install if not
if ! [[ -f /opt/homebrew/bin/brew ]]; then
echo -e "${green}Installing Homebrew...${end}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
export PATH="/opt/homebrew/bin:$PATH"

brew install llvm@14 googletest google-benchmark lcov make wget cmake curl bash python3 pylint python-matplotlib
brew upgrade bash

# Add Python 3 to PATH
echo "export PATH=\"/opt/homebrew/opt/python@3/bin:\$PATH\"" >> ~/.bash_profile
# Make python3 default
echo "alias python=python3" >> ~/.bash_profile
. ~/.bash_profile

CLANG_TIDY=/usr/local/bin/clang-tidy
if [ ! -L "$CLANG_TIDY" ]; then
$SUDO ln -s $(brew --prefix)/opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy
Expand All @@ -27,9 +57,8 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
if [ ! -L "$GMAKE" ]; then
$SUDO ln -s $(xcode-select -p)/usr/bin/gnumake /usr/local/bin/gmake
fi
fi

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

Expand All @@ -38,7 +67,20 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
$SUDO apt install -y clang-format-14 clang-tidy-14
$SUDO ln -s -f $(which clang-format-14) /usr/local/bin/clang-format
$SUDO ln -s -f $(which clang-tidy-14) /usr/local/bin/clang-tidy

# Python 3.10+ not installed so get the latest version
if ! check_python_version; then
$SUDO add-apt-repository ppa:deadsnakes/ppa
$SUDO apt update

latest_python_version=$(apt-cache search python3. | grep -o 'python3\.[0-9]*' | sort -V | tail -n 1)
$SUDO apt install -y $latest_python_version

$SUDO update-alternatives --install /usr/bin/python3 python3 /usr/bin/$(ls /usr/bin/ | grep -E '^python3\.[0-9]+$' | sort -V | tail -n 1) 1
$SUDO update-alternatives --config python3
fi
fi
python3 --version

PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py
if [ ! -f "${PYTHON_TIDY}" ]; then
Expand Down
3 changes: 1 addition & 2 deletions scripts/setup-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ end="\033[0m"
set -e

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

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

0 comments on commit 3b9400a

Please sign in to comment.