When installing TA-Lib in a Dockerfile which inherits from python:3.10.13-slim-bookworm I am using these Dockerfiles as examples however still am getting errors:
https://dev.to/lazypro/build-a-small-ta-lib-container-image-4ca1
Example errors I am seeing:
Problem with the CMake installation, aborting build. CMake executable is cmake
CMake was unable to find a build program corresponding to "Ninja".
Unit test failures:
Could not build wheels for patchelf, which is required to install pyproject.toml-based projects
FAIL: set-interpreter-long.sh
FAIL: set-rpath.sh
FAIL: add-rpath.sh
How do I install TA-Lib into a Dockerfile?
I didn't try installing anaconda and using conda to install TA-Lib but that might have been easier, as mentioned here: https://blog.quantinsti.com/install-ta-lib-python/
Instead here is my full Dockerfile. In particular I think it was the various pip and apt-get installs which allowed my TA-Lib make/install to succeed:
FROM python:3.10.13-slim-bookworm
WORKDIR /app
ENV PYTHON_TA_LIB_VERSION 0.4.17
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y gcc wget python3-dev musl-dev g++ make cmake autoconf ninja-build vim
COPY . .
RUN pip3 install --upgrade pip
RUN pip3 install setuptools numpy patchelf
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
cd ta-lib/ && \
./configure --prefix=/usr && \
make && \
make install
ENV TA_LIBRARY_PATH="/usr/lib"
ENV TA_INCLUDE_PATH="/usr/include"
RUN pip3 install --global-option=build_ext --global-option="-L/usr/lib" TA-Lib
RUN pip3 install -r requirements.txt
ENV PATH="/usr/bin:$PATH"
ENV LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH"
ENV PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
ENTRYPOINT ["sleep", "infinity"]