Skip to content

Commit 7635866

Browse files
authored
Merge pull request #53 from deepnote/ach/python-3.12-support
Add support for python 3.12
2 parents 53040bf + a60ab8a commit 7635866

File tree

6 files changed

+143
-5
lines changed

6 files changed

+143
-5
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"

python/base/Dockerfile.base

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ RUN apt-get update \
2121
ssh \
2222
gnupg2 \
2323
ca-certificates \
24+
# Required for Python packages that need to connect to MS SQL Server (like pymssql)
25+
freetds-dev \
26+
# Enables Python to connect to various databases through ODBC drivers
27+
unixodbc-dev \
28+
# Required for secure network communications (HTTPS, secure database connections)
29+
libssl-dev \
2430
&& apt-get clean \
2531
&& rm -rf /var/lib/apt/lists/*
2632
ENV SHELL=/bin/bash \

python/datascience/Dockerfile.datascience

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ ARG CIRCLE_PULL_REQUEST
33
FROM deepnote/python:${PYTHON_VERSION}${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}
44

55
# Add the requirements files
6-
ADD requirements-3.11+.txt /requirements-3.11+.txt
6+
ADD requirements-3.11.txt /requirements-3.11.txt
7+
ADD requirements-3.12.txt /requirements-3.12.txt
78
ADD requirements-below-3.11.txt /requirements-below-3.11.txt
89

910
#Determine the Python version and set the version-specifications file
1011
ARG PYTHON_VERSION
1112

12-
RUN if [ "$(printf '%s\n' "$PYTHON_VERSION" "3.11" | sort -V | head -n1)" = "3.11" ]; then \
13-
mv "requirements-3.11+.txt" "requirements.txt" \
13+
RUN if [ "$(printf '%s\n' "$PYTHON_VERSION" "3.12" | sort -V | head -n1)" = "3.12" ]; then \
14+
mv /requirements-3.12.txt /requirements.txt \
15+
; elif [ "$(printf '%s\n' "$PYTHON_VERSION" "3.11" | sort -V | head -n1)" = "3.11" ]; then \
16+
mv /requirements-3.11.txt /requirements.txt \
1417
; else \
15-
mv "requirements-below-3.11.txt" "requirements.txt" \
18+
mv /requirements-below-3.11.txt /requirements.txt \
1619
; fi
1720

18-
1921
RUN python -m venv --system-site-packages ~/venv
2022
RUN . ~/venv/bin/activate \
2123
&& pip install --no-cache-dir -r requirements.txt -c https://tk.deepnote.com/constraints${PYTHON_VERSION}.txt
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Requirements for Python 3.12
2+
# Package versions use '<=' to specify maximum compatible versions
3+
# This prevents unexpected breaking changes while allowing installation
4+
# of the latest compatible version within the specified constraints
5+
scipy<=1.15.2
6+
matplotlib<=3.10.0
7+
scikit-learn<=1.6.0
8+
agate<=1.13.0
9+
keras<=3.9.0
10+
nltk<=3.9.0
11+
spacy<=3.8.0
12+
seaborn<=0.13.1
13+
scrapy<=2.11.0
14+
jsonify==0.5
15+
datascience>=0.17,<1
16+
textblob<=0.19.0
17+
tabulate<=0.9.0
18+
sympy<=1.14.0
19+
squarify<=0.4.3
20+
tensorflow>=2.15,<3
21+
torch<=2.7.0
22+
torchvision<=0.17.0
23+
snowflake-snowpark-python<=1.31.0
24+
geopandas<=1.0.0
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+
ARG CIRCLE_PULL_REQUEST
7+
FROM deepnote/python:base${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}
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)