Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility of adding Python 3.10? #4

Open
matthewfeickert opened this issue Feb 2, 2023 · 1 comment
Open

Possibility of adding Python 3.10? #4

matthewfeickert opened this issue Feb 2, 2023 · 1 comment

Comments

@matthewfeickert
Copy link

@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 wheel

when 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.9

The undesirable thing here of course is that Python 3.8 is still the system default

$ $(command -v python3) --version
Python 3.8.10

but 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).

@Moelf
Copy link
Contributor

Moelf commented Oct 14, 2024

now that 3.8 is EOL, should we add something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants