Don't only install python3-virtualenv

We added this sed in I422490ebe9a9c655552685bc2ff342d288335a9c to
avoid installing python2 packages on python3-only systems and thus
dragging in all of python2.

We made a similar change to python-pip in
I7d8ba9300039cce90965410a4e16ca9e711904c3; however we realised that
the gate (and other consumers) were relying on this element having
installed the python2 & 3 packages for consistency -- otherwise jobs
would install the python-pip packages and overwrite the
pip-from-source and mess everything up.  We reverted that in
I419dbdf4682394db68974944af1e5c432f3e0565 and added some clearer notes
that this element brings in python2 & 3, and if you want something
that doesn't do that then this element isn't for you.

However, we never fixed up the virtualenv package install -- currently
our Xenial images have a global virtualenv installed from source, but
the python-virtualenv packages aren't installed.  Thus if a job does
"apt-get install python-virtualenv" it overwrites the from-source
virtualenv with older parts and again messes everything up.

Probably most jobs just call "virtualenv" and assume it is there;
however in bringing up some rspec test for puppet I have hit this
issue as some modules specify dependencies on the virtualenv packages.

Thus install the python-virtualenv AND python3-virtualenv packages in
this element.

Change-Id: Ia84c38dc3c40a6080e144b563e10abca7dac2881
This commit is contained in:
Ian Wienand 2018-04-10 10:44:10 +10:00
parent f3d58d9042
commit f52b385818

View File

@ -110,12 +110,13 @@ 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 python3-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=$(echo "$packages" | sed s/python-virtualenv/python3-virtualenv/) packages+=" python3-virtualenv"
fi fi
apt-get -y install $packages apt-get -y install $packages