Skip to content

Commit

Permalink
Adjust "pip" installation to match the recent changes in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
tianon committed Jun 8, 2017
1 parent 52cb11e commit 198e58c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 80 deletions.
32 changes: 16 additions & 16 deletions 2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ ENV PYPY_SHA256SUM c4fa3da42156bed4a9d912433b618a141e0c5161d7cc8c328786736ea5d1c
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex \
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2" \
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
&& rm pypy.tar.bz2 \
RUN set -ex; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy2-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2

RUN set -ex; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& pypy /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
&& rm /tmp/get-pip.py \
# 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
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
&& pip install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
# then we use "pip list" to ensure we don't have more than one pip version installed
# https://github.com/docker-library/python/pull/100
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
pypy get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
&& rm -rf ~/.cache
rm -f get-pip.py

CMD ["pypy"]
42 changes: 21 additions & 21 deletions 2/slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:jessie
FROM debian:jessie-slim

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

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

CMD ["pypy"]
35 changes: 16 additions & 19 deletions 3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ ENV PYPY_SHA256SUM 2abaa54d88c9b70b64c37083e7e430a1d3a8f78f8de92e484a988b7aca1e5
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex \
&& wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2" \
&& echo "$PYPY_SHA256SUM pypy.tar.bz2" | sha256sum -c \
&& tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2 \
&& rm pypy.tar.bz2 \
RUN set -ex; \
wget -O pypy.tar.bz2 "https://bitbucket.org/pypy/pypy/downloads/pypy3-v${PYPY_VERSION}-linux64.tar.bz2"; \
echo "$PYPY_SHA256SUM *pypy.tar.bz2" | sha256sum -c; \
tar -xjC /usr/local --strip-components=1 -f pypy.tar.bz2; \
rm pypy.tar.bz2

RUN set -ex; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
# explicit path to "pip3" to ensure distribution-provided "pip3" cannot interfere
&& if [ ! -e /usr/local/bin/pip3 ]; then : \
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& pypy3 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
&& rm /tmp/get-pip.py \
; fi \
# 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
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
&& pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
# then we use "pip list" to ensure we don't have more than one pip version installed
# https://github.com/docker-library/python/pull/100
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
pypy3 get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
&& rm -rf ~/.cache
rm -f get-pip.py

CMD ["pypy3"]
45 changes: 21 additions & 24 deletions 3/slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:jessie
FROM debian:jessie-slim

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

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

CMD ["pypy3"]

0 comments on commit 198e58c

Please sign in to comment.