1- # syntax=docker/dockerfile:1
21##############################################################
3- # This Dockerfile builds a base image with a free-threaded
4- # build of Python 3.13.
5- #
6- # This is EXPERIMENTAL and intended for development and
7- # testing purposes only.
2+ # Builds a base image with free-threaded Python 3.13
83##############################################################
94
105ARG FROM_IMAGE=ubuntu:22.04
@@ -27,9 +22,7 @@ RUN git clone --depth 1 --branch 3.13 https://github.com/python/cpython.git /usr
2722
2823WORKDIR /usr/src/cpython
2924
30- # Configure, compile, and install Python with the free-threaded build
31- # --disable-gil: The key flag to enable the free-threaded build
32- # --enable-optimizations: Apply profile-guided optimizations for better performance
25+ # Configure, build, and install Python 3.13 with the GIL disabled
3326RUN ./configure --prefix=/opt/python3 --disable-gil --enable-optimizations
3427RUN make -j$(nproc)
3528RUN make install
@@ -39,19 +32,16 @@ FROM $FROM_IMAGE
3932
4033ARG DEBIAN_FRONTEND=noninteractive
4134
42- # Copy our Python build from the builder stage
35+ # Copy Python build from the previous stage
4336COPY --from=builder /opt/python3/ /opt/python3/
4437
45- # Set the PATH to include our custom Python build
38+ # Set the PATH to include custom Python build
4639ENV PATH="/opt/python3/bin:${PATH}"
4740
48- # Install essential runtime dependencies.
49- # Downstream images are responsible for installing Devito-specific
50- # dependencies such as compilers/MPI.
41+ # Install some Python runtime dependencies
5142RUN apt-get update && apt-get install -y \
5243 libnuma-dev && \
5344 rm -rf /var/lib/apt/lists/*
5445
5546RUN python3 -m pip install --upgrade pip && \
5647 python3 -m pip cache purge
57-
0 commit comments