2015-10-27 01:49:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
2017-04-06 14:19:40 +00:00
|
|
|
if [[ $DISTRO_NAME =~ (opensuse|fedora|centos|centos7|rhel|rhel7) ]]; then
|
2016-07-14 03:43:06 +00:00
|
|
|
# GENERAL WARNING : mixing packaged python libraries with
|
|
|
|
# pip-installed versions always creates issues. Upstream
|
|
|
|
# openstack-infra uses this a lot (especially devstack) but be
|
|
|
|
# warned: here be dragons :)
|
|
|
|
|
|
|
|
# Firstly we want to install the system packages. Otherwise later
|
|
|
|
# on somebody does a "yum install python-virtualenv" and goes and
|
|
|
|
# overwrites the pip installed version with the packaged version,
|
|
|
|
# leading to all sorts of weird version issues.
|
2017-02-22 18:59:44 +00:00
|
|
|
if [[ $DISTRO_NAME = opensuse ]]; then
|
|
|
|
zypper -n install python-virtualenv python-pip python-setuptools
|
|
|
|
else
|
|
|
|
${YUM:-yum} install -y python-virtualenv python-pip python-setuptools
|
|
|
|
fi
|
2016-07-14 03:43:06 +00:00
|
|
|
|
2017-04-11 00:38:22 +00:00
|
|
|
# install the latest pip; this overwrites packaged pip
|
|
|
|
${DIB_PYTHON} /tmp/get-pip.py
|
2016-07-14 03:43:06 +00:00
|
|
|
|
|
|
|
# pip and setuptools are closely related; we want to ensure the
|
|
|
|
# latest for sanity. Because distro packages don't include enough
|
|
|
|
# info in the egg for pip to be certain it has fully uninstalled
|
|
|
|
# the old package, for safety we clear it out by hand (this seems
|
|
|
|
# to have been a problem with very old to new updates,
|
|
|
|
# e.g. centos6 to current-era, but less so for smaller jumps).
|
|
|
|
# There is a bit of chicken-and-egg problem with pip in that it
|
|
|
|
# requires setuptools for some operations, such as wheel creation.
|
|
|
|
# But just installing setuptools shouldn't require setuptools
|
|
|
|
# itself, so we are safe for this small section.
|
|
|
|
rm -rf /usr/lib/python2.7/site-packages/setuptools*
|
|
|
|
pip install -U setuptools
|
|
|
|
|
|
|
|
# now install latest virtualenv. it vendors stuff it needs so
|
|
|
|
# doesn't have issues with other system packages.
|
|
|
|
pip install -U virtualenv
|
|
|
|
|
2017-02-22 18:59:44 +00:00
|
|
|
if [[ $DISTRO_NAME = opensuse ]]; then
|
|
|
|
for pkg in virtualenv pip setuptools; do
|
|
|
|
cat - >> /etc/zypp/locks <<EOF
|
|
|
|
type: package
|
|
|
|
match_type: glob
|
|
|
|
case_sensitive: on
|
|
|
|
solvable_name: python-$pkg
|
|
|
|
EOF
|
|
|
|
done
|
2016-07-14 03:43:06 +00:00
|
|
|
else
|
2017-02-22 18:59:44 +00:00
|
|
|
# Add this to exclude so that we don't install a later package
|
|
|
|
# over it if it updates. Note that fedora-minimal, bootstrapped
|
|
|
|
# via yum, can have an old yum.conf around, so look for dnf first.
|
|
|
|
if [[ -f /etc/dnf/dnf.conf ]]; then
|
|
|
|
conf=/etc/dnf/dnf.conf
|
|
|
|
elif [[ -f /etc/yum.conf ]]; then
|
|
|
|
conf=/etc/yum.conf
|
|
|
|
else
|
|
|
|
die "No conf to modify?"
|
|
|
|
fi
|
|
|
|
echo "exclude=python-virtualenv,python-pip,python-setuptools" >> ${conf}
|
2016-07-14 03:43:06 +00:00
|
|
|
fi
|
|
|
|
else
|
2017-04-11 00:38:22 +00:00
|
|
|
${DIB_PYTHON} /tmp/get-pip.py
|
2016-07-14 03:43:06 +00:00
|
|
|
pip install virtualenv
|
|
|
|
fi
|