Ian Wienand 6dce7ba605 ensure-pip: export ensure_pip_virtualenv_command
This makes ensure-pip export something that should be sensible for
users of pip: to put in their 'virtualenv_command' for their host.

The theory of operation is fairly simple; see if "python3 -m venv"
looks like it works, and set that as the command if it does.  If not,
set "virtualenv".  For sanity, we check if it works.

We pull in virtualenv in the Python 2 case, but for Python 3 we are
deliberately do not bring it as it is an unnecessary dependency.  If
jobs do require the actual `virtualenv` package, they should provision
it themselves ... except for Xenial, which, as described inline, has
issues.

Follow-on changes will convert existing zuul-jobs roles that install
tools into virtualenvs to use this argument.

Change-Id: Idad14c0e77eed5bf8df2c8f84f52fbdea2236a9f
2020-04-15 15:34:19 -07:00

21 lines
450 B
YAML

# See notes in main.yaml about the virtualenv requirements
- name: Install Python 3 pip
package:
name:
- python3-pip
- python3-setuptools
- python3-venv
- python3-virtualenv
become: yes
- name: Install Python 2 pip
package:
name:
- python-setuptools
- python-pip
- python-virtualenv
become: yes
when: (ensure_pip_from_packages_with_python2) or
(ansible_python.version.major == 2)