-
Notifications
You must be signed in to change notification settings - Fork 3
Description
@ivukotic Would you be open to adding a more modern version of CPython than 3.8, such as Python 3.10, as NEP 29 advocates support for Python 3.8 be dropped for the PyData stack in 2023 and deadsnakes is already being used?
The following Dockerfile
ARG BASE_IMAGE=nvidia/cuda:11.4.3-devel-ubuntu20.04
FROM ${BASE_IMAGE} as base
FROM base
SHELL [ "/bin/bash", "-c" ]
USER root
ARG PYTHON_VERSION_LOW="3.6"
ARG PYTHON_VERSION_HIGH="3.10"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
wget \
unzip \
zip \
vim \
jq \
rsync \
software-properties-common && \
add-apt-repository -y 'ppa:deadsnakes/ppa' && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install \
python"${PYTHON_VERSION_LOW}" \
python"${PYTHON_VERSION_LOW}"-venv \
python"${PYTHON_VERSION_LOW}"-dev \
python"${PYTHON_VERSION_HIGH}" \
python"${PYTHON_VERSION_HIGH}"-venv \
python"${PYTHON_VERSION_HIGH}"-dev \
binutils \
binfmt-support && \
apt-get -y autoclean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
RUN python"${PYTHON_VERSION_HIGH}" -m ensurepip --upgrade && \
python"${PYTHON_VERSION_LOW}" -m ensurepip --upgrade && \
python"${PYTHON_VERSION_LOW}" -m pip --no-cache-dir install --upgrade pip setuptools wheel && \
python"${PYTHON_VERSION_HIGH}" -m pip --no-cache-dir install --upgrade pip setuptools wheelwhen built
docker build -f Dockerfile -t ivukotic/ml_base:issue-4 .
allows for Python 3.6 and Python 3.10 to have virtual environment control, and as Python 3.8 is getting brought along vestigially it is ignored (not sure if that can be avoided when getting the other packages — I think no).
This results in a working Python 3.6 and Python 3.10 with pip and venv control:
$ docker run --rm -ti ivukotic/ml_base:issue-4
root@73bf5d827485:/# python3.6 -m venv python3.6-venv && . python3.6-venv/bin/activate && python --version && deactivate
Python 3.6.15
root@73bf5d827485:/# python3.10 -m venv python3.10-venv && . python3.10-venv/bin/activate && python --version && deactivate
Python 3.10.9The undesirable thing here of course is that Python 3.8 is still the system default
$ $(command -v python3) --version
Python 3.8.10but in a (admittedly not good hack) you could somewhat get around that with an alias to python3.10 (or hopefully something more robust and intelligent then what I can think of at the moment).