Install only python3 pip in debian bullseye

Debian bullseye has removed python-pip and python-virtualenv
from its repos, let's install only pip and virtualenv python3 modules.

Also split pip installation based on python2 and python3 for
debian-based distributions.

Change-Id: I2b75afd310f009ae8614f6ca75bb984b56d25c45
This commit is contained in:
Riccardo Pittau 2021-12-06 17:40:03 +01:00
parent a2b8d4d846
commit 4f151aeeb5

View File

@ -6,6 +6,24 @@ fi
set -eu set -eu
set -o pipefail set -o pipefail
# NOTES on pip install functions
# It's all installed into /usr/local/bin so override any packages, even
# if installed later.
# NOTE(dpawlik): The get-pip.py script is not based on master release.
# Ensure that uses the latest available version.
function install_python3_pip {
python3 /tmp/get-pip.py $pip_args
python3 -m pip install $pip_args pip
pip3 install $pip_args virtualenv
}
function install_python2_pip {
python2 /tmp/get-pip.py $pip_args
python2 -m pip install $pip_args pip
pip install $pip_args virtualenv
}
if [[ $DISTRO_NAME =~ (opensuse|fedora|centos|centos7|rhel|rhel7) ]]; then if [[ $DISTRO_NAME =~ (opensuse|fedora|centos|centos7|rhel|rhel7) ]]; then
# Default packages # Default packages
@ -233,16 +251,21 @@ elif [[ $DISTRO_NAME = gentoo ]]; then
packages="dev-python/pip dev-python/virtualenv" packages="dev-python/pip dev-python/virtualenv"
emerge -U $packages emerge -U $packages
else else
if [[ $DIB_RELEASE = bullseye ]]; then
packages="python3-pip python3-virtualenv"
apt-get -y install $packages
install_python3_pip
else
# pre-install packages so dependencies are there. We will # pre-install packages so dependencies are there. We will
# overwrite with latest below. # overwrite with latest below.
packages="python-pip python3-pip python-virtualenv" packages="python-pip python-virtualenv"
# Unfortunately older ubuntu (trusty) doesn't have a # Unfortunately older ubuntu (trusty) doesn't have a
# python3-virtualenv package -- it seems it wasn't ready at the # python3-virtualenv package -- it seems it wasn't ready at the
# time and you had to use "python -m venv". Since then virtualenv # time and you had to use "python -m venv". Since then virtualenv
# has gained 3.4 support so the pip install below will work # has gained 3.4 support so the pip install below will work
if [[ ${DIB_PYTHON_VERSION} == 3 ]]; then if [[ ${DIB_PYTHON_VERSION} == 3 ]]; then
packages+=" python3-virtualenv" packages+="python3-pip python3-virtualenv"
fi fi
apt-get -y install $packages apt-get -y install $packages
@ -250,17 +273,9 @@ else
# force things to happen so our assumptions hold # force things to happen so our assumptions hold
pip_args="-U --force-reinstall" pip_args="-U --force-reinstall"
# These install into /usr/local/bin so override any packages, even install_python2_pip
# if installed later. if [[ ${DIB_PYTHON_VERSION} == 3 ]]; then
install_python3_pip
python3 /tmp/get-pip.py $pip_args fi
python2 /tmp/get-pip.py $pip_args fi
# NOTE(dpawlik) The get-pip.py script is not base on master release.
# Ensure that is uses latest available version.
python3 -m pip install $pip_args pip
python2 -m pip install $pip_args pip
pip3 install $pip_args virtualenv
pip install $pip_args virtualenv
fi fi