Sign inSign up

caiolombello/python-llvm

By caiolombello

•Updated almost 3 years ago

Docker image with Alpine Linux, Python, LLVM and llvmlite for JIT compilation and optimizations.

Image
0

48

caiolombello/python-llvm repository overview

⁠Docker image for Python with LLVM and llvmlite

This Docker image is based on Alpine Linux and includes a full installation of Python, the LLVM compiler, and the llvmlite library. It is an optimized configuration for running Python applications that require LLVM resources for Just-In-Time (JIT) compilation and other low-level optimizations.

⁠Characteristics:

  • Based on Alpine Linux for a lightweight and secure image.
  • Includes Python 3.
  • LLVM in version 14, compatible with llvmlite.
  • llvmlite compiled from source code.
  • Includes essential development tools such as git, gcc, g++, and make.

Ideal for Python applications that require real-time compilation and optimization, especially when efficient use of resources is a priority.

Dockerfile:

FROM alpine:3.18.4

# Instalar dependências básicas e ferramentas de compilação
RUN apk add --no-cache \
    git \
    gcc \
    g++ \
    make \
    cmake \
    musl-dev \
    llvm \
    python3 \
    py3-pip

# Define a variável de ambiente LLVM_CONFIG
ENV LLVM_CONFIG=/usr/bin/llvm-config

# Clone LLVM e llvmlite repositórios
RUN git clone https://github.com/llvm/llvm-project.git \
    && cd llvm-project \
    && git checkout tags/llvmorg-14.0.0 \
    && cd .. \
    && git clone https://github.com/numba/llvmlite.git

# Compilar LLVM
WORKDIR /llvm-project/llvm
# Criar um diretório de build e mudar para ele
RUN mkdir build && cd build \
    # Executar cmake e make a partir do diretório de build
    && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. \
    && make -j4

ENV LLVM_CONFIG=/llvm-project/llvm/build/bin/llvm-config

# Compilar llvmlite
WORKDIR /llvmlite

RUN python setup.py build \
    && python setup.py install \
    && cd / \
    && rm -rf /llvm-project /llvmlite

Tag summary

Content type

Image

Digest

sha256:b88429983…

Size

3.2 GB

Last updated

almost 3 years ago

docker pull caiolombello/python-llvm:3.11-alpine