From 7a962e9d1cb4c680dcbc7c73c7080c0bd9e90a39 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 12 Apr 2017 05:49:47 +1000 Subject: [PATCH] Skip python3-virtualenv on <= trusty If DIB_PYTHON_VERSION is < 3 on the !redhat path, that means we're on an older platform that may not have python3-virtualenv packages. Skip install. Ensure the order of operations happens by forcing the installs Also add a note about limited platform support (patches welcome :) Change-Id: I18412767f0ebf946d557a0a126285369e96af159 --- .../elements/pip-and-virtualenv/README.rst | 3 +++ .../04-install-pip | 27 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/diskimage_builder/elements/pip-and-virtualenv/README.rst b/diskimage_builder/elements/pip-and-virtualenv/README.rst index 5217f62ff..bf79ff2f6 100644 --- a/diskimage_builder/elements/pip-and-virtualenv/README.rst +++ b/diskimage_builder/elements/pip-and-virtualenv/README.rst @@ -47,6 +47,9 @@ The system will be left in the following state: (note python3 ``virtualenv`` script is *not* installed, see below) +Source install is supported on limited platforms. See the code, but +this includes Ubuntu and RedHat platforms. + Using the tools =============== diff --git a/diskimage_builder/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/04-install-pip b/diskimage_builder/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/04-install-pip index 932c8031a..1f368b2dd 100755 --- a/diskimage_builder/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/04-install-pip +++ b/diskimage_builder/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/04-install-pip @@ -101,15 +101,28 @@ EOF echo "exclude=$packages" >> ${conf} fi else - # pre-install packages, we will overwrite with latest below - apt-get -y install python-pip python3-pip \ - python-virtualenv python3-virtualenv + # pre-install packages so depedencies are there. We will + # overwrite with latest below. + packages="python-pip python3-pip python-virtualenv" + # unfortunately older ubuntu (trusty) doesn't have a + # python3-virtualenv package -- it seems it wasn't ready at the + # time and you had to use "python -m venv". Since then virtualenv + # has gained 3.4 support so the pip install below will work + if [[ ${DIB_PYTHON_VERSION} == 3 ]]; then + packages+=" python3-virtualenv" + fi + + apt-get -y install $packages + + # force things to happen so our assumptions hold + pip_args="-U --force-reinstall" # 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 virtualenv - pip install virtualenv + python3 /tmp/get-pip.py $pip_args + python2 /tmp/get-pip.py $pip_args + + pip3 install $pip_args virtualenv + pip install $pip_args virtualenv fi