@@ -52,58 +52,41 @@ RUN apt-get update \
5252 wget \
5353 zlib1g-dev \
5454 && add-apt-repository universe \
55+ && add-apt-repository ppa:deadsnakes/ppa \
5556 && apt-get update \
5657 && apt-get -y install jq \
5758 && apt-get clean autoclean \
5859 && apt-get autoremove -y \
60+ && apt install -y python3.10-distutils \
5961 && rm -rf /var/lib/apt/lists/* \
6062 && rm -f /var/cache/apt/archives/*.deb
6163
62- COPY fetch_gpg_keys.sh /tmp
63- # Install the desired versions of Python.
64- RUN set -ex \
65- && export GNUPGHOME="$(mktemp -d)" \
66- && echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \
67- && /tmp/fetch_gpg_keys.sh \
68- && for PYTHON_VERSION in 3.9.13; do \
69- wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
70- && wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
71- && gpg --batch --verify python-${PYTHON_VERSION}.tar.xz.asc python-${PYTHON_VERSION}.tar.xz \
72- && rm -r python-${PYTHON_VERSION}.tar.xz.asc \
73- && mkdir -p /usr/src/python-${PYTHON_VERSION} \
74- && tar -xJC /usr/src/python-${PYTHON_VERSION} --strip-components=1 -f python-${PYTHON_VERSION}.tar.xz \
75- && rm python-${PYTHON_VERSION}.tar.xz \
76- && cd /usr/src/python-${PYTHON_VERSION} \
77- && ./configure \
78- --enable-shared \
79- # This works only on Python 2.7 and throws a warning on every other
80- # version, but seems otherwise harmless.
81- --enable-unicode=ucs4 \
82- --with-system-ffi \
83- --without-ensurepip \
84- && make -j$(nproc) \
85- && make install \
86- && ldconfig \
87- ; done \
88- && rm -rf "${GNUPGHOME}" \
89- && rm -rf /usr/src/python* \
90- && rm -rf ~/.cache/
91-
92- # Install pip on Python 3.9 only.
93- # If the environment variable is called "PIP_VERSION", pip explodes with
94- # "ValueError: invalid truth value '<VERSION>'"
95- ENV PYTHON_PIP_VERSION 23.0
96- RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
97- && python3.9 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
98- # we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
99- # ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.10/site-packages")
100- # https://github.com/docker-library/python/pull/143#issuecomment-241032683
101- && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
102- # then we use "pip list" to ensure we don't have more than one pip version installed
103- # https://github.com/docker-library/python/pull/100
104- && [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == " pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ]
105-
10664# Install Google Cloud SDK
10765RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-sdk -y
10866
67+
68+ # ##################### Install python 3.10.13
69+
70+ # Download python 3.10.13
71+ RUN wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz
72+
73+ # Extract files
74+ RUN tar -xvf Python-3.10.13.tgz
75+
76+ # Install python 3.10.13
77+ RUN ./Python-3.10.13/configure --enable-optimizations
78+ RUN make altinstall
79+
80+ # ##################### Install pip
81+ RUN apt install -y python3-pip
82+
83+ # Test pip
84+ RUN python3.10 -m pip
85+
86+ # Make Python3.10 the default version
87+ RUN unlink /usr/bin/python3 && ln -s /usr/local/bin/python3.10 /usr/bin/python3
88+
89+ # Test version
90+ RUN python3 --version
91+
10992CMD ["python3" ]
0 commit comments