2020-05-22 06:00:08 +03:00
|
|
|
#!/bin/bash
|
2020-04-06 11:19:25 +03:00
|
|
|
echo "This requires the chia python virtual environment."
|
|
|
|
echo "Execute '. ./activate' if you have not already, before running."
|
2020-05-21 01:59:57 +03:00
|
|
|
echo "This version of Timelord requires CMake 3.14+ to compile vdf_client"
|
|
|
|
|
2020-05-22 06:00:08 +03:00
|
|
|
PYTHON_VERSION=$(python -c 'import sys; print(f"python{sys.version_info.major}.{sys.version_info.minor}")')
|
|
|
|
echo "Python version: $PYTHON_VERSION"
|
2020-05-21 01:59:57 +03:00
|
|
|
|
2020-04-18 02:17:36 +03:00
|
|
|
export BUILD_VDF_BENCH=Y # Installs the useful vdf_bench test of CPU squaring speed
|
2020-05-22 06:00:08 +03:00
|
|
|
THE_PATH=$(python -c 'import pkg_resources; print( pkg_resources.get_distribution("chiavdf").location)' 2> /dev/null)/vdf_client
|
|
|
|
CHIAVDF_VERSION=$(python -c 'from setup import dependencies; t = [_ for _ in dependencies if _.startswith("chiavdf")][0]; print(t)')
|
2020-04-06 03:52:34 +03:00
|
|
|
|
2020-05-22 06:00:08 +03:00
|
|
|
ubuntu_cmake_install() {
|
|
|
|
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
|
|
|
|
if [ "$UBUNTU_PRE_2004" = "True" ]; then
|
|
|
|
echo "Ubuntu version is pre 20.04LTS - installing CMake with snap"
|
|
|
|
sudo apt-get install snap -y
|
|
|
|
sudo apt-get remove --purge cmake -y
|
|
|
|
hash -r
|
|
|
|
sudo snap install cmake --classic
|
|
|
|
else
|
|
|
|
echo "Ubuntu 20.04LTS and newer support CMake 3.16+"
|
|
|
|
sudo apt-get install cmake -y
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
symlink_vdf_bench() {
|
|
|
|
if [ ! -e vdf_bench ] && [ -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
|
|
|
echo ln -s venv/lib/"$1"/site-packages/vdf_bench
|
|
|
|
ln -s venv/lib/"$1"/site-packages/vdf_bench .
|
|
|
|
elif [ ! -e venv/lib/"$1"/site-packages/vdf_bench ]; then
|
|
|
|
echo "ERROR: Could not find venv/lib/$1/site-packages/vdf_bench"
|
|
|
|
else
|
|
|
|
echo "./vdf_bench link exists"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$(uname)" = "Linux" ] && type apt-get; then
|
|
|
|
UBUNTU_DEBIAN=true
|
2020-04-06 04:57:35 +03:00
|
|
|
echo "Found Ubuntu/Debian"
|
2020-05-22 06:00:08 +03:00
|
|
|
elif [ "$(uname)" = "Darwin" ]; then
|
|
|
|
MACOS=true
|
2020-04-08 22:42:12 +03:00
|
|
|
echo "Found MacOS"
|
2020-04-06 03:43:03 +03:00
|
|
|
fi
|
|
|
|
|
2020-05-22 06:00:08 +03:00
|
|
|
if [ -e "$THE_PATH" ]; then
|
|
|
|
echo "$THE_PATH"
|
2020-03-28 01:59:25 +03:00
|
|
|
echo "vdf_client already exists, no action taken"
|
|
|
|
else
|
2020-05-22 06:00:08 +03:00
|
|
|
if [ -e venv/bin/python ] && test $UBUNTU_DEBIAN; then
|
2020-04-08 22:50:30 +03:00
|
|
|
echo "Installing chiavdf from source on Ubuntu/Debian"
|
2020-05-22 06:00:08 +03:00
|
|
|
# If Ubuntu version is older than 20.04LTS then upgrade CMake
|
|
|
|
ubuntu_cmake_install
|
|
|
|
# Install remaining needed development tools - assumes venv and prior run of install.sh
|
2020-09-22 09:08:26 +03:00
|
|
|
echo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
|
|
|
sudo apt-get install libgmp-dev libboost-python-dev lib"$PYTHON_VERSION"-dev libboost-system-dev build-essential -y
|
2020-05-22 06:00:08 +03:00
|
|
|
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
|
|
|
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
|
|
|
symlink_vdf_bench "$PYTHON_VERSION"
|
|
|
|
elif [ -e venv/bin/python ] && test $MACOS && brew info boost | grep -q 'Not installed'; then
|
|
|
|
echo "Installing chiavdf requirement boost for MacOS"
|
2020-04-08 22:50:30 +03:00
|
|
|
brew install boost
|
2020-05-22 06:00:08 +03:00
|
|
|
echo "installing chiavdf from source"
|
2020-04-18 03:20:24 +03:00
|
|
|
# User needs to provide required packages
|
2020-05-22 06:00:08 +03:00
|
|
|
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
|
|
|
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
2020-05-24 01:47:01 +03:00
|
|
|
symlink_vdf_bench "$PYTHON_VERSION"
|
2020-05-22 06:00:08 +03:00
|
|
|
elif [ -e venv/bin/python ]; then
|
2020-04-06 04:22:51 +03:00
|
|
|
echo "installing chiavdf from source"
|
|
|
|
# User needs to provide required packages
|
2020-05-22 06:00:08 +03:00
|
|
|
echo venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
|
|
|
venv/bin/python -m pip install --force --no-binary chiavdf "$CHIAVDF_VERSION"
|
2020-05-24 01:47:01 +03:00
|
|
|
symlink_vdf_bench "$PYTHON_VERSION"
|
2020-03-28 01:59:25 +03:00
|
|
|
else
|
|
|
|
echo "no venv created yet, please run install.sh"
|
|
|
|
fi
|
|
|
|
fi
|
2020-05-22 06:00:08 +03:00
|
|
|
echo "To estimate a timelord on this CPU try './vdf_bench square_asm 400000' for an ips estimate"
|