Failed to install llvm-lite with a Dockerfile

1.3k Views Asked by At

The scenario below is blocking me to have progressed in dockerize my Flask App, anybody has any clue about it? some important info below.

I already see about setting the LLVM_CONFIG file to the right path but which path and how to do that during the docker build process?

  • pip 20.2.3

  • python 3.8

Below the Dockerfile:

FROM python:3.8-alpine
RUN adduser -D ddc-user
WORKDIR /ddc
COPY . /ddc
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
     && apk --no-cache --update-cache add postgresql-dev g++ linux-headers gfortran libffi-dev openssl-dev gcc build-base bash libpng-dev openblas-dev wget freetype-dev python3-dev py3-pip \
     && ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc openssl-dev curl
RUN apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev
RUN pip install --upgrade pip
RUN pip install Pillow
RUN LLVM_CONFIG=/tmp/pip-install-3knaaqva/llvmlite/ffi/llvm-config pip install llvmlite==0.34.0
RUN apk add --no-cache --virtual .build-deps gcc musl-dev
RUN pip install numpy pyyaml
RUN pip install setuptools wheel
RUN pip install cython
RUN pip install -r requirements.txt
RUN chmod +x boot.sh
ENV FLASK_APP main.py
RUN chown -R ddc-user:users ./
USER ddc-user
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]

Below the error:

Collecting llvmlite==0.34.0
  Downloading llvmlite-0.34.0.tar.gz (107 kB)
Building wheels for collected packages: llvmlite
  Building wheel for llvmlite (setup.py): started
  Building wheel for llvmlite (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pe4psx4_/llvmlite/setup.py'"'"'; __file__='"'"'/t
mp/pip-install-pe4psx4_/llvmlite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close()
;exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-skfgived
       cwd: /tmp/pip-install-pe4psx4_/llvmlite/
  Complete output (26 lines):
  running bdist_wheel
  /usr/local/bin/python /tmp/pip-install-pe4psx4_/llvmlite/ffi/build.py

  LLVM version... Traceback (most recent call last):
    File "/tmp/pip-install-pe4psx4_/llvmlite/ffi/build.py", line 105, in main_posix
      out = subprocess.check_output([llvm_config, '--version'])
    File "/usr/local/lib/python3.8/subprocess.py", line 411, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "/usr/local/lib/python3.8/subprocess.py", line 489, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-3knaaqva/llvmlite/ffi/llvm-config'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/tmp/pip-install-pe4psx4_/llvmlite/ffi/build.py", line 191, in <module>
      main()
    File "/tmp/pip-install-pe4psx4_/llvmlite/ffi/build.py", line 181, in main
      main_posix('linux', '.so')
    File "/tmp/pip-install-pe4psx4_/llvmlite/ffi/build.py", line 107, in main_posix
      raise RuntimeError("%s failed executing, please point LLVM_CONFIG "
  RuntimeError: /tmp/pip-install-3knaaqva/llvmlite/ffi/llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
  error: command '/usr/local/bin/python' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for llvmlite
1

There are 1 best solutions below

1
On

Firstly, LLVM-Lite requires LLVM.

So, it's necessary to install the LLVM correctly, to do this:

RUN apt-get update && apt-get install -y \
    build-essential \
    libedit-dev  \
    llvm-{version} \
    llvm-{version}-dev

Then, set the environment variable used when building LLVM-Lite and install pip package:

RUN LLVM_CONFIG=/usr/bin/llvm-config-{version} pip install llvmlite=={version}

This will solve your problem.

To find out which version of LLVM is compatible with each version of LLVM-Lite go to: