81 lines
2.4 KiB
Bash
Executable File
81 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
if [[ $DISTRO_NAME =~ (opensuse|fedora|centos|centos7|rhel|rhel7) ]]; then
|
|
|
|
if [[ $DISTRO_NAME =~ (centos7) ]]; then
|
|
|
|
# note python3 in epel
|
|
_extra_repo="--enablerepo=epel"
|
|
packages="python3 python3-devel"
|
|
|
|
${YUM:-yum} ${_extra_repo} install -y $packages
|
|
|
|
fi
|
|
|
|
# install the latest python2 pip; this overwrites packaged pip
|
|
python /tmp/get-pip.py
|
|
|
|
# Install latest setuptools; there is a slight chicken-egg issue in
|
|
# that pip requires setuptools for some operations like building a
|
|
# wheel. But this simple install should be fine.
|
|
pip install setuptools
|
|
|
|
# Repeat above for python3
|
|
|
|
# python2 on fedora always installs into /usr/bin. Move pip2
|
|
# binary out, as we want "pip" in the final image to be
|
|
# python2 for historical reasons.
|
|
mv /usr/bin/pip /usr/bin/pip2
|
|
|
|
# You would think that installing python3 bits first, then
|
|
# python2 would work -- alas get-pip.py doesn't seem to leave
|
|
# python3 alone:
|
|
# https://github.com/pypa/pip/issues/4435
|
|
python3 /tmp/get-pip.py
|
|
pip3 install setuptools
|
|
|
|
# on < 27, this installed pip3 to /usr/bin/pip. On >=27 it's
|
|
# /usr/local/bin/pip. reclaim /usr/bin/pip back to pip2 and
|
|
# remove the /usr/local/bin/pip (i.e. python3 version) if it
|
|
# exists, so that "pip" calls pip2 always. if we want pip3 we
|
|
# call it explicitly.
|
|
ln -sf /usr/bin/pip2 /usr/bin/pip
|
|
rm -f /usr/local/bin/pip
|
|
|
|
# now install latest virtualenv. it vendors stuff it needs so
|
|
# doesn't have issues with other system packages.
|
|
pip install virtualenv
|
|
mv /usr/bin/virtualenv /usr/bin/virtualenv2
|
|
pip3 install virtualenv
|
|
|
|
# Reclaim virtualenv to virtualenv2; similar to above, on fedora
|
|
# >27 the pip3 version has gone into /usr/local/bin; remove it so
|
|
# only /usr/bin/virtualenv exists
|
|
ln -sf /usr/bin/virtualenv2 /usr/bin/virtualenv
|
|
rm -f /usr/local/bin/virtualenv
|
|
|
|
# at this point, we should have the latest
|
|
# pip/setuptools/virtualenv packages for python2 & 3, and
|
|
# "/usr/bin/pip" and "/usr/bin/virtualenv" should be python2
|
|
# versions.
|
|
|
|
else
|
|
|
|
# Debuntu
|
|
|
|
# These install into /usr/local/bin so override any packages, even
|
|
# if installed later.
|
|
|
|
python3 /tmp/get-pip.py
|
|
python2 /tmp/get-pip.py
|
|
|
|
pip3 install setuptools virtualenv
|
|
pip install setuptools virtualenv
|
|
fi
|