Skip to content

Switch to unconditional invocation of "get-pip.py" #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions 2.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.13

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1
ENV PYTHON_SETUPTOOLS_VERSION 35.0.2
ENV PYTHON_WHEEL_VERSION 0.29.0

RUN set -ex \
&& buildDeps=' \
tcl-dev \
Expand All @@ -42,29 +37,41 @@ RUN set -ex \
&& ./configure \
--enable-shared \
--enable-unicode=ucs4 \
&& make -j$(nproc) \
&& make -j "$(nproc)" \
&& make install \
&& ldconfig \
\
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python2 /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" \
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \
"wheel==$PYTHON_WHEEL_VERSION" \
&& apt-get purge -y --auto-remove $buildDeps \
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -rf /usr/src/python ~/.cache
&& rm -rf /usr/src/python

# 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 get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py

# install "virtualenv", since the vast majority of users of this image will want it
RUN pip install --no-cache-dir virtualenv
Expand Down
59 changes: 35 additions & 24 deletions 2.7/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ RUN apk add --no-cache ca-certificates
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.13

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1
ENV PYTHON_SETUPTOOLS_VERSION 35.0.2
ENV PYTHON_WHEEL_VERSION 0.29.0

RUN set -ex \
&& apk add --no-cache --virtual .fetch-deps \
gnupg \
Expand Down Expand Up @@ -60,26 +55,9 @@ RUN set -ex \
&& ./configure \
--enable-shared \
--enable-unicode=ucs4 \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make -j "$(getconf _NPROCESSORS_ONLN)" \
&& make install \
\
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python2 /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" \
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \
"wheel==$PYTHON_WHEEL_VERSION" \
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
Expand All @@ -89,6 +67,39 @@ RUN set -ex \
)" \
&& apk add --virtual .python-rundeps $runDeps \
&& apk del .build-deps \
&& rm -rf /usr/src/python ~/.cache
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& rm -rf /usr/src/python

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
apk add --no-cache --virtual .fetch-deps openssl; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
apk del .fetch-deps; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spacing between the lines seems maybe a bit excessive..but nbd.

Also not sure about mixing the styles:

RUN set -x \
  && foo \
...

with

RUN set -ex; \
  foo; \
...

but that's really up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit odd, but it does help with the cross-variant diffs (doing vimdiff across all the different variants in this repo gets pretty tedious, so any little bit helps). 😇 👍

Switching to semicolons is something I thought about doing to the whole file, but decided to keep the change smaller for now. We've been trying to switch most things over to semicolons (slowly), especially after having fun with things like foo && for xxx; do something-that-might-fail; done && bar, which creates a "complex expression", and thus the rules for failure change (such that the for xxx; do ...; done bit of that expression will only fail if the final iteration fails, for example).

From https://www.gnu.org/software/bash/manual/bashref.html#index-set:

The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !.

Thanks for taking a look 😄

\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py

CMD ["python2"]
49 changes: 31 additions & 18 deletions 2.7/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.13

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1
ENV PYTHON_SETUPTOOLS_VERSION 35.0.2
ENV PYTHON_WHEEL_VERSION 0.29.0

RUN set -ex \
&& buildDeps=' \
gcc \
Expand Down Expand Up @@ -57,28 +52,46 @@ RUN set -ex \
&& ./configure \
--enable-shared \
--enable-unicode=ucs4 \
&& make -j$(nproc) \
&& make -j "$(nproc)" \
&& make install \
&& ldconfig \
\
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python2 /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" \
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \
"wheel==$PYTHON_WHEEL_VERSION" \
&& apt-get purge -y --auto-remove $buildDeps \
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -rf /usr/src/python ~/.cache
&& rm -rf /usr/src/python

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends wget; \
rm -rf /var/lib/apt/lists/*; \
\
wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
apt-get purge -y --auto-remove wget; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py

CMD ["python2"]
43 changes: 25 additions & 18 deletions 2.7/wheezy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.13

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1
ENV PYTHON_SETUPTOOLS_VERSION 35.0.2
ENV PYTHON_WHEEL_VERSION 0.29.0

RUN set -ex \
&& buildDeps=' \
tcl-dev \
Expand All @@ -42,29 +37,41 @@ RUN set -ex \
&& ./configure \
--enable-shared \
--enable-unicode=ucs4 \
&& make -j$(nproc) \
&& make -j "$(nproc)" \
&& make install \
&& ldconfig \
\
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
&& python2 /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" \
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \
"wheel==$PYTHON_WHEEL_VERSION" \
&& apt-get purge -y --auto-remove $buildDeps \
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -rf /usr/src/python ~/.cache
&& rm -rf /usr/src/python

# 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 get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py

# install "virtualenv", since the vast majority of users of this image will want it
RUN pip install --no-cache-dir virtualenv
Expand Down
17 changes: 11 additions & 6 deletions 2.7/windows/windowsservercore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV PYTHON_VERSION 2.7.13
ENV PYTHON_RELEASE 2.7.13

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}.amd64.msi' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
(New-Object System.Net.WebClient).DownloadFile($url, 'python.msi'); \
Expand All @@ -34,10 +31,18 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}.amd64.msi' -f $env
Write-Host 'Removing ...'; \
Remove-Item python.msi -Force; \
\
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
Write-Host ('Installing {0} ...' -f $pipInstall); \
Write-Host 'Complete.';

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1

RUN Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
(New-Object System.Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'get-pip.py'); \
python get-pip.py $pipInstall; \
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
; \
Remove-Item get-pip.py -Force; \
\
Write-Host 'Verifying pip install ...'; \
Expand Down
48 changes: 26 additions & 22 deletions 3.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ENV GPG_KEY 26DEA9D4613391EF3E25C9FF0A5B101836580288
ENV PYTHON_VERSION 3.3.6

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 9.0.1
ENV PYTHON_SETUPTOOLS_VERSION 35.0.2
ENV PYTHON_WHEEL_VERSION 0.29.0

RUN set -ex \
&& buildDeps=' \
tcl-dev \
Expand All @@ -48,39 +43,48 @@ RUN set -ex \
&& ./configure \
--enable-loadable-sqlite-extensions \
--enable-shared \
&& make -j$(nproc) \
--without-ensurepip \
&& make -j "$(nproc)" \
&& make install \
&& ldconfig \
\
# 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' \
&& python3 /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" \
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \
"wheel==$PYTHON_WHEEL_VERSION" \
&& apt-get purge -y --auto-remove $buildDeps \
\
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -rf /usr/src/python ~/.cache
&& rm -rf /usr/src/python

# make some useful symlinks that are expected to exist
RUN cd /usr/local/bin \
&& { [ -e easy_install ] || ln -s easy_install-* easy_install; } \
&& ln -s idle3 idle \
&& ln -s pydoc3 pydoc \
&& ln -s python3 python \
&& ln -s python3-config python-config

# 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 get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py

CMD ["python3"]
Loading