Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ python-versions: &python-versions
- "3.9"
- "3.10"
- "3.11"
- "3.12"

r-versions: &r-versions
- "4.0.4"
Expand Down
6 changes: 6 additions & 0 deletions python/base/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ RUN apt-get update \
ssh \
gnupg2 \
ca-certificates \
# Required for Python packages that need to connect to MS SQL Server (like pymssql)
freetds-dev \
# Enables Python to connect to various databases through ODBC drivers
unixodbc-dev \
# Required for secure network communications (HTTPS, secure database connections)
libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV SHELL=/bin/bash \
Expand Down
12 changes: 7 additions & 5 deletions python/datascience/Dockerfile.datascience
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ ARG CIRCLE_PULL_REQUEST
FROM deepnote/python:${PYTHON_VERSION}${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}

# Add the requirements files
ADD requirements-3.11+.txt /requirements-3.11+.txt
ADD requirements-3.11.txt /requirements-3.11.txt
ADD requirements-3.12.txt /requirements-3.12.txt
ADD requirements-below-3.11.txt /requirements-below-3.11.txt

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

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


RUN python -m venv --system-site-packages ~/venv
RUN . ~/venv/bin/activate \
&& pip install --no-cache-dir -r requirements.txt -c https://tk.deepnote.com/constraints${PYTHON_VERSION}.txt
24 changes: 24 additions & 0 deletions python/datascience/requirements-3.12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Requirements for Python 3.12
# Package versions use '<=' to specify maximum compatible versions
# This prevents unexpected breaking changes while allowing installation
# of the latest compatible version within the specified constraints
scipy<=1.15.2
matplotlib<=3.10.0
scikit-learn<=1.6.0
agate<=1.13.0
keras<=3.9.0
nltk<=3.9.0
spacy<=3.8.0
seaborn<=0.13.1
scrapy<=2.11.0
jsonify==0.5
datascience>=0.17,<1
textblob<=0.19.0
tabulate<=0.9.0
sympy<=1.14.0
squarify<=0.4.3
tensorflow>=2.15,<3
torch<=2.7.0
torchvision<=0.17.0
snowflake-snowpark-python<=1.31.0
geopandas<=1.0.0
105 changes: 105 additions & 0 deletions python/python/Dockerfile.python3.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
## WARNING: This image is plane copy of:
## https://github.com/docker-library/python/blob/7c8595e8e2b1c8bca0b6d9d146675b94c2a37ec7/3.11/bullseye/Dockerfile
## This is temporary solution and we come with proper solution in the future.
## Ticket: https://linear.app/deepnote/issue/PLA-3219/cleanup-build-pipeline-for-deepnote-python-images

ARG CIRCLE_PULL_REQUEST
FROM deepnote/python:base${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH

# cannot remove LANG even though https://bugs.python.org/issue19846 is fixed
# last attempted removal of LANG broke many users:
# https://github.com/docker-library/python/pull/570
ENV LANG C.UTF-8

# runtime dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
libbluetooth-dev \
tk-dev \
uuid-dev \
; \
rm -rf /var/lib/apt/lists/*

ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305
ENV PYTHON_VERSION 3.12.7

RUN set -eux; \
\
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"; \
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; \
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-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking=fatal \
--enable-shared \
--with-lto \
--with-system-expat \
--with-ensurepip \
; \
nproc="$(nproc)"; \
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
make -j "$nproc" \
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
"LDFLAGS=${LDFLAGS:-}" \
"PROFILE_TASK=${PROFILE_TASK:-}" \
; \
# https://github.com/docker-library/python/issues/784
# prevent accidental usage of a system installed libpython of the same version
rm python; \
make -j "$nproc" \
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
"PROFILE_TASK=${PROFILE_TASK:-}" \
python \
; \
make install; \
\
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701
bin="$(readlink -ve /usr/local/bin/python3)"; \
dir="$(dirname "$bin")"; \
mkdir -p "/usr/share/gdb/auto-load/$dir"; \
cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \
\
cd /; \
rm -rf /usr/src/python; \
\
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; \
\
export PYTHONDONTWRITEBYTECODE=1; \
python3 --version; \
pip3 --version

# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
RUN set -eux; \
for src in idle3 pip3 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

CMD ["python3"]