Skip to content

Commit

Permalink
Merge branch 'main' into nico/add-compilation-pyo3
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq authored Oct 12, 2023
2 parents f72d9f9 + f2d172d commit e6fd6f6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Empty file modified scripts/run_node2.sh
100644 → 100755
Empty file.
59 changes: 59 additions & 0 deletions shinkai-libs/shinkai-message-pyo3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Use CentOS 7 as base image
FROM centos:7

# Install necessary development tools and libraries
RUN yum groupinstall -y "Development Tools"

# Install necessary libraries for building Python with custom SSL support
RUN yum install -y wget zlib-devel libffi-devel gcc make epel-release patchelf

# Build and install OpenSSL from source
RUN wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz && \
tar -xzf openssl-1.1.1l.tar.gz && \
cd openssl-1.1.1l && \
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl && \
make && make install && \
cd .. && \
rm -rf openssl-1.1.1l.tar.gz openssl-1.1.1l

# Set environment variables for building Python
ENV LDFLAGS="-L/usr/local/ssl/lib"
ENV LD_LIBRARY_PATH="/usr/local/ssl/lib:/usr/local/lib"
ENV CPPFLAGS="-I/usr/local/ssl/include"
ENV OPENSSL_DIR=/usr/local/ssl
ENV OPENSSL_LIB_DIR=/usr/local/ssl/lib
ENV OPENSSL_INCLUDE_DIR=/usr/local/ssl/include

# Download and install Python 3.10 with custom SSL support
RUN wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz && \
tar -xzf Python-3.10.0.tgz && \
cd Python-3.10.0 && \
./configure --enable-optimizations --with-ensurepip=install --with-openssl=/usr/local/ssl --enable-shared && \
make altinstall && \
cd .. && \
rm -rf Python-3.10.0.tgz Python-3.10.0

# Set python3.10 and pip3.10 as the default python and pip versions
RUN ln -sf /usr/local/bin/python3.10 /usr/bin/python && \
ln -sf /usr/local/bin/pip3.10 /usr/bin/pip && \
ln -s /usr/local/lib/libpython3.10.so /usr/lib/ && \
ln -s /usr/local/lib/libpython3.10.so.1.0 /usr/lib/

# Install Rust and Cargo (using Rust version 1.72.0)
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.72.0
ENV PATH="/root/.cargo/bin:${PATH}"
ENV PYO3_PYTHON=“/usr/local/lib/libpython3.10.so”

# Install maturin
RUN pip install maturin

# Check and ensure SSL for Python
RUN python --version && \
python -c "import ssl; print(ssl.OPENSSL_VERSION)"

# Set the working directory
WORKDIR /project

# Entrypoint
CMD ["/bin/bash"]

0 comments on commit e6fd6f6

Please sign in to comment.