From 8a7959e2063077639827093daa30345ab57fbff9 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 20 May 2024 09:04:14 +0200 Subject: [PATCH] The ta-lib install script is a tiny bit outdated (last modified 2006-07-02) so this additional download enables building the docker image on ARM architecture to us it on a RaspbarryPi. --- Dockerfile | 2 +- docker_build_helpers/install_ta-lib.sh | 46 ++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 019358485..7c11d6036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.9-slim AS jesse_basic_env ENV PYTHONUNBUFFERED 1 RUN apt-get update \ - && apt-get -y install git build-essential libssl-dev \ + && apt-get -y install git build-essential libssl-dev wget \ && apt-get clean \ && pip install --upgrade pip diff --git a/docker_build_helpers/install_ta-lib.sh b/docker_build_helpers/install_ta-lib.sh index bac363df6..f74be0b93 100755 --- a/docker_build_helpers/install_ta-lib.sh +++ b/docker_build_helpers/install_ta-lib.sh @@ -1,17 +1,51 @@ +#!/bin/bash + if [ -z "$1" ]; then INSTALL_LOC=/usr/local else INSTALL_LOC=${1} fi echo "Installing to ${INSTALL_LOC}" + if [ ! -f "${INSTALL_LOC}/lib/libta_lib.a" ]; then + # Download and extract ta-lib source tar zxvf ta-lib-0.4.0-src.tar.gz - cd ta-lib \ - && sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h \ - && ./configure --prefix=${INSTALL_LOC}/ \ - && make \ - && which sudo && sudo make install || make install \ - && echo "export LD_LIBRARY_PATH=/usr/local/lib" >> /root/.bashrc + cd ta-lib + + # Update config.guess and config.sub + echo "Downloading updated config.guess and config.sub from savannah.gnu.org" + wget -O config.guess 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess' + wget -O config.sub 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub' + + # Apply patch and configure + sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h + ./configure --prefix=${INSTALL_LOC}/ + + # Build and install + make + if which sudo; then + sudo make install + else + make install + fi + + # Update library path + echo "export LD_LIBRARY_PATH=/usr/local/lib" >> /root/.bashrc + + # Verify installation + if [ -f "${INSTALL_LOC}/include/ta-lib/ta_defs.h" ]; then + echo "TA-Lib headers installed successfully." + else + echo "Error: TA-Lib headers not found." + exit 1 + fi + + if [ -f "${INSTALL_LOC}/lib/libta_lib.a" ]; then + echo "TA-Lib library installed successfully." + else + echo "Error: TA-Lib library not found." + exit 1 + fi else echo "TA-lib already installed, skipping installation" fi