Skip to content

Commit 924dd7d

Browse files
committed
Add support for python 3.12
1 parent 53040bf commit 924dd7d

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ python-versions: &python-versions
272272
- "3.9"
273273
- "3.10"
274274
- "3.11"
275+
- "3.12"
275276

276277
r-versions: &r-versions
277278
- "4.0.4"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
## WARNING: This image is plane copy of:
2+
## https://github.com/docker-library/python/blob/7c8595e8e2b1c8bca0b6d9d146675b94c2a37ec7/3.11/bullseye/Dockerfile
3+
## This is temporary solution and we come with proper solution in the future.
4+
## Ticket: https://linear.app/deepnote/issue/PLA-3219/cleanup-build-pipeline-for-deepnote-python-images
5+
6+
7+
FROM buildpack-deps:bullseye
8+
9+
# ensure local python is preferred over distribution python
10+
ENV PATH /usr/local/bin:$PATH
11+
12+
# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed
13+
# last attempted removal of LANG broke many users:
14+
# https://github.com/docker-library/python/pull/570
15+
ENV LANG C.UTF-8
16+
17+
# runtime dependencies
18+
RUN set -eux; \
19+
apt-get update; \
20+
apt-get install -y --no-install-recommends \
21+
libbluetooth-dev \
22+
tk-dev \
23+
uuid-dev \
24+
; \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305
28+
ENV PYTHON_VERSION 3.12.7
29+
30+
RUN set -eux; \
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+
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
35+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \
36+
gpg --batch --verify python.tar.xz.asc python.tar.xz; \
37+
gpgconf --kill all; \
38+
rm -rf "$GNUPGHOME" python.tar.xz.asc; \
39+
mkdir -p /usr/src/python; \
40+
tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \
41+
rm python.tar.xz; \
42+
\
43+
cd /usr/src/python; \
44+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
45+
./configure \
46+
--build="$gnuArch" \
47+
--enable-loadable-sqlite-extensions \
48+
--enable-optimizations \
49+
--enable-option-checking=fatal \
50+
--enable-shared \
51+
--with-lto \
52+
--with-system-expat \
53+
--with-ensurepip \
54+
; \
55+
nproc="$(nproc)"; \
56+
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
57+
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
58+
make -j "$nproc" \
59+
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
60+
"LDFLAGS=${LDFLAGS:-}" \
61+
"PROFILE_TASK=${PROFILE_TASK:-}" \
62+
; \
63+
# https://github.com/docker-library/python/issues/784
64+
# prevent accidental usage of a system installed libpython of the same version
65+
rm python; \
66+
make -j "$nproc" \
67+
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
68+
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
69+
"PROFILE_TASK=${PROFILE_TASK:-}" \
70+
python \
71+
; \
72+
make install; \
73+
\
74+
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701
75+
bin="$(readlink -ve /usr/local/bin/python3)"; \
76+
dir="$(dirname "$bin")"; \
77+
mkdir -p "/usr/share/gdb/auto-load/$dir"; \
78+
cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \
79+
\
80+
cd /; \
81+
rm -rf /usr/src/python; \
82+
\
83+
find /usr/local -depth \
84+
\( \
85+
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
86+
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
87+
\) -exec rm -rf '{}' + \
88+
; \
89+
\
90+
ldconfig; \
91+
\
92+
export PYTHONDONTWRITEBYTECODE=1; \
93+
python3 --version; \
94+
pip3 --version
95+
96+
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
97+
RUN set -eux; \
98+
for src in idle3 pip3 pydoc3 python3 python3-config; do \
99+
dst="$(echo "$src" | tr -d 3)"; \
100+
[ -s "/usr/local/bin/$src" ]; \
101+
[ ! -e "/usr/local/bin/$dst" ]; \
102+
ln -svT "$src" "/usr/local/bin/$dst"; \
103+
done
104+
105+
CMD ["python3"]

0 commit comments

Comments
 (0)