4a139969e1
We have two diametrically opposed use cases amongst our user base. The first are the folks who just need tox/virtualenv to pre-exist, so that they can do things like run tests. Neither tox nor virtualenv themselves are fundamental to the thing under test, but are tools that need to exist. The second are folks for whom tools like pip or virtualenv are essential to the software (such as OSA). For these users, it is important that the version of those match what they expect their users get from the distro. Up until now, we've been using the pip-and-virtualenv element from DIB which installs distro versions of pip and virtualenv, then overwrites them with pip installed versions of the same, doing what it can to prevent subsequent distro installs of the packages from breaking things. This produces a really strange environment for our friends in teh second camp, but honestly is a weird scenarios to wrap the head around. Instead, remove ALL distro packages of pip and virtualenv. Then install both via get-pip. But - also leave a cleanup script. Since pip installs are pretty well self-contained, it's easy to remove them with a simple "rm". This cleanup script can be run by folks like OSA in their first pre-playbook in zuul, and then their jobs can subsequently apt-get or dnf install python3-virtualenv or whatever they want to do that is appropriate. Change-Id: Ifd9062e5a87923093e84b3e4fc933dc08375df82 |
||
---|---|---|
.. | ||
bin | ||
environment.d | ||
install.d | ||
post-install.d | ||
element-deps | ||
package-installs.yaml | ||
pkg-map | ||
README.rst | ||
source-repository-pip-and-virtualenv |
simple-pip
This element installs pip and virtualenv in the image.
get-pip
The simple-pip element removes all distro packages for pip and virtualenv and then installs pip from get-pip.py and virtualenv from pip.
The system will be left in the following state:
/usr/bin/pip
: python2 pip/usr/bin/pip2
: python2 pip (same as prior)/usr/bin/pip3
: python3 pip/usr/bin/virtualenv
: python2 virtualenv
(note python3 virtualenv
script is not
installed, see below)
Explicit use of the tools
Due to the essentially unsolvable problem of "who owns the script",
it is recommended to not call pip
or
virtualenv
directly. You can directly call them with the
-m
argument to the python interpreter you wish to install
with.
For example, to create a python3 environment do:
# python3 -m virtualenv myenv
# myenv/bin/pip install mytool
To install a python2 tool from pip:
# python2 -m pip install mytool
In this way, you can always know which interpreter is being used (and affected by) the call.
cleanup-pip.sh
A script is provided, /usr/local/bin/cleanup-pip.sh
which will uninstall pip installed pip and virtualenv. This script is
suitable to be used in Zuul jobs where the job content wants to install
its own pip or virtualenv infrastructure.
Ordering
Any element that uses these commands must be designated as 05-* or higher to ensure that they are first installed.