Skip to content

Commit 33edeaf

Browse files
committed
Adjust "pip" installation to match the recent changes in Python
1 parent 52cb11e commit 33edeaf

File tree

4 files changed

+74
-80
lines changed

4 files changed

+74
-80
lines changed

2/Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ ENV PYPY_SHA256SUM c4fa3da42156bed4a9d912433b618a141e0c5161d7cc8c328786736ea5d1c
1919
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
2020
ENV PYTHON_PIP_VERSION 9.0.1
2121

22-
RUN set -ex \
23-
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2" \
24-
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
25-
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
26-
&& rm pypy.tar.bz2 \
22+
RUN set -ex; \
23+
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2"; \
24+
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
25+
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
26+
rm pypy.tar.bz2
27+
28+
RUN set -ex; \
29+
\
30+
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
2731
\
28-
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
29-
&& pypy /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
30-
&& rm /tmp/get-pip.py \
31-
# 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
32-
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
33-
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
34-
&& pip install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
35-
# then we use "pip list" to ensure we don't have more than one pip version installed
36-
# https://github.com/docker-library/python/pull/100
37-
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
32+
pypy get-pip.py \
33+
--disable-pip-version-check \
34+
--no-cache-dir \
35+
"pip==$PYTHON_PIP_VERSION" \
36+
; \
37+
pip --version; \
3838
\
39-
&& rm -rf ~/.cache
39+
rm -f get-pip.py
4040

4141
CMD ["pypy"]

2/slim/Dockerfile

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:jessie
1+
FROM debian:jessie-slim
22

33
# ensure local pypy is preferred over distribution python
44
ENV PATH /usr/local/bin:$PATH
@@ -21,30 +21,30 @@ ENV PYPY_SHA256SUM c4fa3da42156bed4a9d912433b618a141e0c5161d7cc8c328786736ea5d1c
2121
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
2222
ENV PYTHON_PIP_VERSION 9.0.1
2323

24-
RUN set -ex \
25-
&& fetchDeps=' \
24+
RUN set -ex; \
25+
\
26+
fetchDeps=' \
2627
bzip2 \
2728
wget \
28-
' \
29-
&& apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
29+
'; \
30+
apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/*; \
31+
\
32+
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2"; \
33+
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
34+
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
35+
rm pypy.tar.bz2; \
36+
\
37+
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
3038
\
31-
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2" \
32-
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
33-
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
34-
&& rm pypy.tar.bz2 \
39+
pypy get-pip.py \
40+
--disable-pip-version-check \
41+
--no-cache-dir \
42+
"pip==$PYTHON_PIP_VERSION" \
43+
; \
44+
pip --version; \
3545
\
36-
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
37-
&& pypy /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
38-
&& rm /tmp/get-pip.py \
39-
# 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
40-
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
41-
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
42-
&& pip install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
43-
# then we use "pip list" to ensure we don't have more than one pip version installed
44-
# https://github.com/docker-library/python/pull/100
45-
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
46+
rm -f get-pip.py; \
4647
\
47-
&& apt-get purge -y --auto-remove $fetchDeps \
48-
&& rm -rf ~/.cache
48+
&& apt-get purge -y --auto-remove $fetchDeps
4949

5050
CMD ["pypy"]

3/Dockerfile

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,23 @@ ENV PYPY_SHA256SUM 2abaa54d88c9b70b64c37083e7e430a1d3a8f78f8de92e484a988b7aca1e5
1919
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
2020
ENV PYTHON_PIP_VERSION 9.0.1
2121

22-
RUN set -ex \
23-
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2" \
24-
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
25-
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
26-
&& rm pypy.tar.bz2 \
22+
RUN set -ex; \
23+
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2"; \
24+
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
25+
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
26+
rm pypy.tar.bz2
27+
28+
RUN set -ex; \
29+
\
30+
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
2731
\
28-
# explicit path to "pip3" to ensure distribution-provided "pip3" cannot interfere
29-
&& if [ ! -e /usr/local/bin/pip3 ]; then : \
30-
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
31-
&& pypy3 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
32-
&& rm /tmp/get-pip.py \
33-
; fi \
34-
# 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
35-
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
36-
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
37-
&& pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
38-
# then we use "pip list" to ensure we don't have more than one pip version installed
39-
# https://github.com/docker-library/python/pull/100
40-
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
32+
pypy3 get-pip.py \
33+
--disable-pip-version-check \
34+
--no-cache-dir \
35+
"pip==$PYTHON_PIP_VERSION" \
36+
; \
37+
pip --version; \
4138
\
42-
&& rm -rf ~/.cache
39+
rm -f get-pip.py
4340

4441
CMD ["pypy3"]

3/slim/Dockerfile

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:jessie
1+
FROM debian:jessie-slim
22

33
# ensure local pypy is preferred over distribution python
44
ENV PATH /usr/local/bin:$PATH
@@ -21,33 +21,30 @@ ENV PYPY_SHA256SUM 2abaa54d88c9b70b64c37083e7e430a1d3a8f78f8de92e484a988b7aca1e5
2121
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
2222
ENV PYTHON_PIP_VERSION 9.0.1
2323

24-
RUN set -ex \
25-
&& fetchDeps=' \
24+
RUN set -ex; \
25+
\
26+
fetchDeps=' \
2627
bzip2 \
2728
wget \
28-
' \
29-
&& apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
29+
'; \
30+
apt-get update && apt-get install -y $fetchDeps --no-install-recommends && rm -rf /var/lib/apt/lists/*; \
31+
\
32+
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2"; \
33+
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
34+
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
35+
rm pypy.tar.bz2; \
36+
\
37+
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
3038
\
31-
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2" \
32-
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
33-
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
34-
&& rm pypy.tar.bz2 \
39+
pypy3 get-pip.py \
40+
--disable-pip-version-check \
41+
--no-cache-dir \
42+
"pip==$PYTHON_PIP_VERSION" \
43+
; \
44+
pip --version; \
3545
\
36-
# explicit path to "pip3" to ensure distribution-provided "pip3" cannot interfere
37-
&& if [ ! -e /usr/local/bin/pip3 ]; then : \
38-
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
39-
&& pypy3 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
40-
&& rm /tmp/get-pip.py \
41-
; fi \
42-
# 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
43-
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
44-
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
45-
&& pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
46-
# then we use "pip list" to ensure we don't have more than one pip version installed
47-
# https://github.com/docker-library/python/pull/100
48-
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
46+
rm -f get-pip.py; \
4947
\
50-
&& apt-get purge -y --auto-remove $fetchDeps \
51-
&& rm -rf ~/.cache
48+
apt-get purge -y --auto-remove $fetchDeps
5249

5350
CMD ["pypy3"]

0 commit comments

Comments
 (0)