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
  • Loading branch information
rockett-m committed Jun 12, 2024
1 parent 7e17ecb commit 5e19d2d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
3 changes: 2 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 Down
43 changes: 42 additions & 1 deletion scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,39 @@ if (( $EUID != 0 )); then
SUDO='sudo'
fi

PYTHON_VERSION="3.10"
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 python@$PYTHON_VERSION
# Add Python 3.10 to PATH
if [[ -f ~/.bash_profile ]]; then
echo "export PATH=\"/opt/homebrew/opt/python@${PYTHON_VERSION}/bin:\$PATH\"" >> ~/.bash_profile
else
echo "export PATH=\"/opt/homebrew/opt/python@${PYTHON_VERSION}/bin:\$PATH\"" > ~/.bash_profile
fi
# Make python3.10 default
echo "export PATH=\"/opt/homebrew/opt/python@${PYTHON_VERSION}/bin:\$PATH\"" >> ~/.bash_profile
echo "alias python=python${PYTHON_VERSION}" >> ~/.bash_profile
. ~/.bash_profile
# Upgrade bash to avoid issues with brew
# see if bash is installed and install if not
if ! [[ -f /opt/homebrew/bin/bash ]]; then
echo -e "${green}Installing Bash...${end}"
/opt/homebrew/bin/brew install bash
else
echo -e "${green}Upgrading Bash...${end}"
/opt/homebrew/bin/brew upgrade bash
fi

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 @@ -38,6 +66,19 @@ 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

# Install Python 3.10
wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
tar xvf Python-3.10.0.tgz
cd Python-3.10.0
./configure --enable-optimizations
make -j $CPUS
sudo make altinstall
cd ..
rm -f Python-3.10.0.tgz
# Make python3.10 default and add to PATH
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python${PYTHON_VERSION} 1
sudo update-alternatives --set python /usr/local/bin/python${PYTHON_VERSION}
fi

PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
fi

# Python 3.10 installed in ./install-build-tools.sh
python3.10 -m pip install --upgrade pip

# Install necessary python packages
if [[ -f requirements.txt ]]; then
python3.10 -m pip install -r requirements.txt
else
python3.10 -m pip install matplotlib pylint
fi

LEVELDB_VERSION="1.23"
echo -e "${green}Building LevelDB from sources...${end}"
wget https://github.com/google/leveldb/archive/${LEVELDB_VERSION}.tar.gz
Expand Down

0 comments on commit 5e19d2d

Please sign in to comment.