Skip to content

Commit dfd482f

Browse files
committed
Fix installation python
1 parent 44f4e99 commit dfd482f

File tree

2 files changed

+31
-48
lines changed

2 files changed

+31
-48
lines changed

python/base/Dockerfile.base

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ ENV DEBIAN_FRONTEND noninteractive
33

44
# Install OS dependencies
55
RUN apt-get update && apt-get -yq dist-upgrade \
6-
&& apt-get install -yq --no-install-recommends \
7-
build-essential \
8-
bzip2 \
9-
cmake \
10-
curl \
11-
git \
12-
graphviz \
13-
libgtk2.0-dev \
14-
locales \
15-
sudo \
16-
unzip \
17-
vim \
18-
wget \
19-
ssh \
20-
gnupg2 \
21-
ca-certificates \
22-
&& apt-get clean \
23-
&& rm -rf /var/lib/apt/lists/*
6+
&& apt-get install -yq --no-install-recommends \
7+
build-essential \
8+
bzip2 \
9+
cmake \
10+
curl \
11+
git \
12+
graphviz \
13+
libgtk2.0-dev \
14+
locales \
15+
sudo \
16+
unzip \
17+
vim \
18+
wget \
19+
ssh \
20+
gnupg2 \
21+
ca-certificates \
22+
&& apt-get clean \
23+
&& rm -rf /var/lib/apt/lists/*
2424

2525
ENV SHELL=/bin/bash \
2626
LC_ALL=en_US.UTF-8 \

python/python/Dockerfile.python

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,33 @@
11
ARG CIRCLE_PULL_REQUEST
2-
FROM debian:bullseye-20241111-slim AS builder
2+
FROM deepnote/python:base${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}
33

44
# Install dependencies for building Python
55
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
wget \
7-
cmake \
86
build-essential \
9-
libssl-dev \
107
zlib1g-dev \
118
libncurses5-dev \
12-
libncursesw5-dev \
13-
libreadline-dev \
14-
libsqlite3-dev \
159
libgdbm-dev \
16-
libdb5.3-dev \
17-
libbz2-dev \
18-
libexpat1-dev \
19-
liblzma-dev \
20-
tk-dev \
10+
libnss3-dev \
11+
libssl-dev \
12+
libreadline-dev \
2113
libffi-dev \
22-
uuid-dev \
14+
libsqlite3-dev \
2315
ca-certificates \
2416
&& apt-get clean \
2517
&& rm -rf /var/lib/apt/lists/*
2618

2719
# Download and extract the Python source code
28-
WORKDIR /tmp
29-
ARG PYTHON_VERSION_PATCH
30-
RUN wget -qO- "https://www.python.org/ftp/python/${PYTHON_VERSION_PATCH}/Python-${PYTHON_VERSION_PATCH}.tgz" | tar xvz \
31-
&& cd "/tmp/Python-${PYTHON_VERSION_PATCH}" \
32-
&& ./configure --enable-optimizations --with-ensurepip=install \
20+
ARG PYTHON_VERSION
21+
RUN cd "/tmp" \
22+
&& wget -qO- "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | tar xvz \
23+
&& cd "/tmp/Python-${PYTHON_VERSION}" \
24+
&& ./configure --enable-optimizations --with-ensurepip=install \
3325
&& make -j "$(nproc)" \
3426
&& make altinstall
3527

36-
37-
FROM deepnote/python:base${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}
38-
# Copy Python from the builder stage
39-
ARG PYTHON_VERSION
40-
# Layers will be different between python versions from here onwards because of the build-arg
41-
42-
COPY --from=builder "/usr/local/bin/python${PYTHON_VERSION}" "/usr/local/bin/python${PYTHON_VERSION}"
43-
COPY --from=builder "/usr/local/bin/pip${PYTHON_VERSION}" "/usr/local/bin/pip${PYTHON_VERSION}"
44-
COPY --from=builder "/usr/local/lib/python${PYTHON_VERSION}" "/usr/local/lib/python${PYTHON_VERSION}"
45-
46-
RUN update-alternatives --install /usr/bin/python python "/usr/local/bin/python${PYTHON_VERSION}" 1
47-
RUN update-alternatives --install /usr/bin/pip pip "/usr/local/bin/pip${PYTHON_VERSION}" 1
28+
RUN PYTHON_MAJOR_MINOR_VERSION="${PYTHON_VERSION%.*}" \
29+
&& ln -s /usr/local/bin/python${PYTHON_MAJOR_MINOR_VERSION} /usr/local/bin/python \
30+
&& ln -s /usr/local/bin/pip${PYTHON_MAJOR_MINOR_VERSION} /usr/local/bin/pip
4831

4932
# We create the virtual environment in the home directory in the Dockerfile
5033
# for performance improvement.

0 commit comments

Comments
 (0)