From 995c539491c72ab338a443099fcf66fb28a4e58b Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 14 Jul 2016 13:43:06 +1000 Subject: [PATCH] Revert "Revert "Pre-install pip/virtualenv packages"" This reverts commit a645fa4ffb3c819f38ce1c66e83eb409c587c55d. It is really devstack causing problems here; it was removing the python-virtualenv package & re-installing using pip (see depends-on). This failed because the pip-install we did here removed the egg-file that rpm expected to be there, so rpm bailed out on the removal. But even if it worked, this just leads you back down the path of the original problem; that the system packaged version can be re-installed and overwrites the pip installed version. Thus I still believe this is the correct thing to do in the dib element. Note it is not a common problem (devstack aside); most jobs don't touch python-virtualenv & related packages (the one we did notice this on was being brought over from travisci where it was required for some reason). Change-Id: I82acb865378a0fa5903a6267bfcee0e2962eced0 Depends-On: Ib0edf6c4ee8a510e9d671213de35d787f56acfed --- .../environment.d/10-centos-distro-name.bash | 3 ++ .../01-install-pip | 49 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/elements/centos-minimal/environment.d/10-centos-distro-name.bash b/elements/centos-minimal/environment.d/10-centos-distro-name.bash index 39449b15..501df444 100644 --- a/elements/centos-minimal/environment.d/10-centos-distro-name.bash +++ b/elements/centos-minimal/environment.d/10-centos-distro-name.bash @@ -4,3 +4,6 @@ export DIB_RELEASE=${DIB_RELEASE:-7} # by default, enable DHCP configuration of eth0 & eth1 in network # scripts. See yum-minimal for full details export DIB_YUM_MINIMAL_CREATE_INTERFACES=${DIB_YUM_MINIMAL_CREATE_INTERFACES:-1} + +# Useful for elements that work with fedora (dnf) & centos +export YUM=${YUM:-yum} diff --git a/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/01-install-pip b/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/01-install-pip index 31804aab..4efd1a21 100755 --- a/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/01-install-pip +++ b/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/01-install-pip @@ -6,5 +6,50 @@ fi set -eu set -o pipefail -python /tmp/get-pip.py -pip install virtualenv +if [[ $DISTRO_NAME =~ (centos|fedora) ]]; then + # 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. + ${YUM:-yum} install -y python-virtualenv python-pip python-setuptools + + # install pip; this overwrites packaged pip + python /tmp/get-pip.py + + # 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 + + # 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} +else + python /tmp/get-pip.py + pip install virtualenv +fi