@@ -7,37 +7,65 @@ FROM howgood/base
77# Copied from python:2.7 https://goo.gl/mz3Aww #
88# ###############################################
99
10- RUN apt-get purge -y python.*
11-
12- # gpg: key 18ADD4FF: public key "Benjamin Peterson <benjamin@python.org>" imported
13- ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
10+ ENV PATH /usr/local/bin:$PATH
1411
1512ENV LANG C.UTF-8
16- ENV PYTHON_VERSION 2.7.12
13+
14+ # runtime dependencies
15+ RUN apt-get update && apt-get install -y --no-install-recommends \
16+ tcl \
17+ tk \
18+ wget \
19+ && rm -rf /var/lib/apt/lists/*
20+
21+ ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
22+ ENV PYTHON_VERSION 2.7.13
23+ ENV PYTHON_PIP_VERSION 9.0.1
1724
1825RUN set -ex \
19- && curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
20- && curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
21- && export GNUPGHOME="$(mktemp -d)" \
22- && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
23- && gpg --batch --verify python.tar.xz.asc python.tar.xz \
24- && rm -r "$GNUPGHOME" python.tar.xz.asc \
25- && mkdir -p /usr/src/python \
26- && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
27- && rm python.tar.xz \
28- \
29- && cd /usr/src/python \
30- && ./configure --enable-shared --enable-unicode=ucs4 \
31- && make -j$(nproc) \
32- && make install \
33- && ldconfig \
34- && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
35- && pip install --no-cache-dir --upgrade --force-reinstall pip \
36- && find /usr/local -depth \
37- \( -type d -a -name test -o -name tests \) \
38- -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
39- -exec rm -rf '{}' + \
40- && rm -rf /usr/src/python ~/.cache /tmp/*
26+ && buildDeps=' \
27+ tcl-dev \
28+ tk-dev \
29+ ' \
30+ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
31+ \
32+ && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
33+ && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
34+ && export GNUPGHOME="$(mktemp -d)" \
35+ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
36+ && gpg --batch --verify python.tar.xz.asc python.tar.xz \
37+ && rm -r "$GNUPGHOME" python.tar.xz.asc \
38+ && mkdir -p /usr/src/python \
39+ && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
40+ && rm python.tar.xz \
41+ \
42+ && cd /usr/src/python \
43+ && ./configure \
44+ --enable-shared \
45+ --enable-unicode=ucs4 \
46+ && make -j$(nproc) \
47+ && make install \
48+ && ldconfig \
49+ \
50+ && wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
51+ && python2 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
52+ && rm /tmp/get-pip.py \
53+ # 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
54+ # ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
55+ # https://github.com/docker-library/python/pull/143#issuecomment-241032683
56+ && pip install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
57+ # then we use "pip list" to ensure we don't have more than one pip version installed
58+ # https://github.com/docker-library/python/pull/100
59+ && [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == " pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
60+ \
61+ && find /usr/local -depth \
62+ \( \
63+ \( -type d -a -name test -o -name tests \) \
64+ -o \
65+ \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
66+ \) -exec rm -rf '{}' + \
67+ && apt-get purge -y --auto-remove $buildDeps \
68+ && rm -rf /usr/src/python ~/.cache /tmp/*
4169
4270# ###########
4371# End copy #
0 commit comments