08bbd16c52
This is part of the efforts to remove pip-and-virtualenv from our base images [1]. There are some users who specifically require the virtualenv command (perhaps, like dib, they have some code that uses the activate_this.py mechanisms it provides wich venv does not). This installs the virtualenv package for the currently running distribution. One of the main maintenance issues of pip-and-virtualenv is that tried to ensure that "virtualenv" created a Python 2 environment always by default. Now that we have Python 3 only distributions like current Fedora, this is not something we can continue to do (even if we wanted to, which we don't). What owns virtualenv and what it produces in our heterogeneous environment is messy, and I think the best we can do is document it as done here. [1] https://docs.opendev.org/opendev/infra-specs/latest/specs/cleanup-test-node-python.html Change-Id: I97d8bfb970ed2b5aaa02a0813899014c94994066 |
||
---|---|---|
.. | ||
tasks | ||
README.rst |
Ensure virtualenv is available
This role installs the requirements for the virtualenv
command on the current distribution.
Users should be aware of some portability issues when using
virtualenv
:
- Distributions differ on the interpreter that
virtualenv
is provided by, so by callingvirtualenv
with no other arguments means that on some platforms you will get a Python 2 environment and others a Python 3 environment. - If you wish to call
virtualenv
as a module (e.g.python -m virtualenv
) you will need to know which interpreter owns thevirtualenv
package for your distribution; e.g. on some, such as Bionic,virtualenv
is provided bypython3-virtualenv
butpython
refers to Python 2, sopython -m virtualenv
is not a portable way to callvirtualenv
. virtualenv -p python3
is likely the most portable way to consistently get a Python 3 environment.virtualenv -p python2
may not work on some platforms without Python 2.- If you use Python 3 and do not require the specific features of
virtualenv
, it is likely easier to use Python's inbuiltpython3 -m venv
module to create an isolated environment. If you are usingpip:
in your Ansible roles and require an environment, see the documentation for :zuulensure-pip
.