From 118e2a4627272fe850d5232ce51f6e7f0f55318e Mon Sep 17 00:00:00 2001 From: Jamie Hewland Date: Fri, 29 Jul 2016 12:55:29 +0200 Subject: [PATCH 1/3] Don't remove python package, rather rename contents --- 2.7/Dockerfile | 17 +++++++++++++++-- 3.5/Dockerfile | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 5c0ed29..8a57025 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,7 +1,20 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 -# remove several traces of alpine python -RUN apk del --purge -r $(apk info | grep '^python') +# rename many traces of Alpine Python (so that they are not used by mistake) +# In the upstream Debian-based images similar files are dpkg-divert'ed but +# Alpine's package manager doesn't have this (obscure) functionality so we just +# rename the files (deleting wouldn't have any advantage since files exist in +# lower layers). We rename all the files in the 'python' package. +RUN set -ex \ + && for bits in \ + /usr/bin/idle \ + /usr/bin/py* \ + /usr/bin/smtpd.py \ + /usr/include/*python* \ + /usr/lib/*python* \ + ; do \ + mv "$bits" "$bits.distrib"; \ + done # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. diff --git a/3.5/Dockerfile b/3.5/Dockerfile index ebf5a77..cd92ade 100644 --- a/3.5/Dockerfile +++ b/3.5/Dockerfile @@ -1,7 +1,20 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 -# remove several traces of alpine python -RUN apk del --purge -r $(apk info | grep '^python') +# rename many traces of Alpine Python (so that they are not used by mistake) +# In the upstream Debian-based images similar files are dpkg-divert'ed but +# Alpine's package manager doesn't have this (obscure) functionality so we just +# rename the files (deleting wouldn't have any advantage since files exist in +# lower layers). We rename all the files in the 'python' package. +RUN set -ex \ + && for bits in \ + /usr/bin/idle \ + /usr/bin/py* \ + /usr/bin/smtpd.py \ + /usr/include/*python* \ + /usr/lib/*python* \ + ; do \ + mv "$bits" "$bits.distrib"; \ + done # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. From 6793ebb0e025eb583c48bb7224349d56a7fd757a Mon Sep 17 00:00:00 2001 From: Jamie Hewland Date: Fri, 29 Jul 2016 14:14:24 +0200 Subject: [PATCH 2/3] Try just delete the package files --- 2.7/Dockerfile | 16 +++------------- 3.5/Dockerfile | 16 +++------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 8a57025..0405a2c 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,20 +1,10 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 -# rename many traces of Alpine Python (so that they are not used by mistake) +# delete many traces of Alpine Python (so that they are not used by mistake) # In the upstream Debian-based images similar files are dpkg-divert'ed but # Alpine's package manager doesn't have this (obscure) functionality so we just -# rename the files (deleting wouldn't have any advantage since files exist in -# lower layers). We rename all the files in the 'python' package. -RUN set -ex \ - && for bits in \ - /usr/bin/idle \ - /usr/bin/py* \ - /usr/bin/smtpd.py \ - /usr/include/*python* \ - /usr/lib/*python* \ - ; do \ - mv "$bits" "$bits.distrib"; \ - done +# delete the files in the single Python package that is installed. +RUN rm $(apk info -q --contents python) # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. diff --git a/3.5/Dockerfile b/3.5/Dockerfile index cd92ade..6fb0834 100644 --- a/3.5/Dockerfile +++ b/3.5/Dockerfile @@ -1,20 +1,10 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 -# rename many traces of Alpine Python (so that they are not used by mistake) +# delete many traces of Alpine Python (so that they are not used by mistake) # In the upstream Debian-based images similar files are dpkg-divert'ed but # Alpine's package manager doesn't have this (obscure) functionality so we just -# rename the files (deleting wouldn't have any advantage since files exist in -# lower layers). We rename all the files in the 'python' package. -RUN set -ex \ - && for bits in \ - /usr/bin/idle \ - /usr/bin/py* \ - /usr/bin/smtpd.py \ - /usr/include/*python* \ - /usr/lib/*python* \ - ; do \ - mv "$bits" "$bits.distrib"; \ - done +# delete the files in the single Python package that is installed. +RUN rm $(apk info -q --contents python) # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. From b37f55d4f2a648eda4eb7dad85e64188edca4e1d Mon Sep 17 00:00:00 2001 From: Jamie Hewland Date: Mon, 1 Aug 2016 15:17:25 +0200 Subject: [PATCH 3/3] Rework explanation of python package file removal --- 2.7/Dockerfile | 8 +++++--- 3.5/Dockerfile | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 0405a2c..6a2f054 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,9 +1,11 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 # delete many traces of Alpine Python (so that they are not used by mistake) -# In the upstream Debian-based images similar files are dpkg-divert'ed but -# Alpine's package manager doesn't have this (obscure) functionality so we just -# delete the files in the single Python package that is installed. +# We can't just uninstall the Python package as we still want things that depend +# on it (e.g. libevent, pcre). We replace this Python with our version built +# from source. In the upstream Debian-based images, the package files are +# dpkg-divert'ed, but Alpine's package manager doesn't have this (obscure) +# functionality so instead we just delete the files. RUN rm $(apk info -q --contents python) # http://bugs.python.org/issue19846 diff --git a/3.5/Dockerfile b/3.5/Dockerfile index 6fb0834..4e0dcde 100644 --- a/3.5/Dockerfile +++ b/3.5/Dockerfile @@ -1,9 +1,11 @@ FROM praekeltfoundation/alpine-buildpack-deps:3.4 # delete many traces of Alpine Python (so that they are not used by mistake) -# In the upstream Debian-based images similar files are dpkg-divert'ed but -# Alpine's package manager doesn't have this (obscure) functionality so we just -# delete the files in the single Python package that is installed. +# We can't just uninstall the Python package as we still want things that depend +# on it (e.g. libevent, pcre). We replace this Python with our version built +# from source. In the upstream Debian-based images, the package files are +# dpkg-divert'ed, but Alpine's package manager doesn't have this (obscure) +# functionality so instead we just delete the files. RUN rm $(apk info -q --contents python) # http://bugs.python.org/issue19846