-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.python
71 lines (65 loc) · 4.44 KB
/
Dockerfile.python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
FROM idein/actcast-rpi-app-base:buster-1
ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV LANG=C.UTF-8
ENV GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568
ENV PYTHON_VERSION=3.9.17
ENV PYTHON_PIP_VERSION=23.0.1
ENV PYTHON_SETUPTOOLS_VERSION=58.1.0
ENV PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/0d8570dc44796f4369b652222cf176b3db6ac70e/public/get-pip.py
ENV PYTHON_GET_PIP_SHA256=96461deced5c2a487ddc65207ec5a9cffeca0d34e7af7ea1afc470ff0d746207
# https://github.com/docker-library/python/issues/160#issuecomment-509426916
ENV PROFILE_TASK="-m test. regrtest pgo test_array test_base64 test_binascii test_binhex test_binop test_c_locale_coercion test_csv test_json test_hashlib test_unicode test_codecs test_traceback test_decimal test_math test_compile test_threading test_time test_fstring test_re test_float test_class test_cmath test_complex test_iter test_struct test_slice test_set test_dict test_long test_bytes test_memoryview test_io test_pickle "
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates netbase tzdata libexpat1 libfreetype6 libjpeg62-turbo \
&& apt-mark showmanual > /savedAptMark \
&& apt-get install -y --no-install-recommends dpkg-dev gcc-8 g++ libbluetooth-dev libbz2-dev libc6-dev libdb-dev libexpat1-dev libffi-dev libgdbm-dev liblzma-dev libncursesw5-dev libreadline-dev libssl-dev make tk-dev uuid-dev wget xz-utils zlib1g-dev libjpeg-dev libfreetype6-dev \
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& wget -O get-pip.py "$PYTHON_GET_PIP_URL" \
&& GNUPGHOME="$(mktemp -d)" \
&& export GNUPGHOME \
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c - \
&& mkdir -p /usr/src/python \
&& tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz \
&& rm python.tar.xz \
&& cd /usr/src/python \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure --build="$gnuArch" --enable-optimizations --with-lto --enable-option-checking=fatal --enable-shared --with-system-expat --without-ensurepip \
&& nproc="$(nproc)" \
&& EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)" \
&& LDFLAGS="$(dpkg-buildflags --get LDFLAGS)" \
&& LDFLAGS="${LDFLAGS:--Wl},--strip-all" \
&& make -j "$nproc" "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" "LDFLAGS=${LDFLAGS:-}" "PROFILE_TASK=${PROFILE_TASK:-}" \
&& rm python \
&& make -j "$nproc" "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" "PROFILE_TASK=${PROFILE_TASK:-}" python \
&& make commoninstall bininstall \
&& cd /root \
&& rm -rf /usr/src/python \
&& for src in idle3 pydoc3 python3 python3-config; do \
dst="$(echo "$src" | tr -d 3)" \
&& [ -s "/usr/local/bin/$src" ] \
&& [ ! -e "/usr/local/bin/$dst" ] \
&& ln -svT "$src" "/usr/local/bin/$dst"; \
done \
&& python3 --version \
&& export PYTHONDONTWRITEBYTECODE=1 \
&& python get-pip.py --disable-pip-version-check --no-cache-dir --no-compile "pip==$PYTHON_PIP_VERSION" "setuptools==$PYTHON_SETUPTOOLS_VERSION" \
&& rm -f get-pip.py \
&& python -m pip wheel --no-cache-dir --wheel-dir=/root/wheels 'numpy==1.25.2' \
&& python -m pip wheel --no-cache-dir --wheel-dir=/root/wheels 'pillow<9.0.0,>=8.0.0' \
&& python -m pip install --no-cache-dir --no-index --find-links=/root/wheels numpy pillow \
&& rm -rf /root/wheels \
&& find /usr/local -depth \( \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \) -exec rm -rf '{}' + \
&& ldconfig \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $(cat /savedAptMark) \
&& find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' | tee /find_ldd.log | awk '/=>/ { print $(NF-1) }' | sort -u | xargs -r dpkg-query --search | cut -d: -f1 | sort -u | xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false libgcc-8-dev perl \
&& apt-get clean \
&& apt-get autoclean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
CMD ["bash"]