diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-20 13:09:58 -0700 |
---|---|---|
committer | Michael Scherer <mscherer@users.noreply.github.com> | 2016-10-20 22:17:36 +0200 |
commit | 653ec28a975182b91a7ef0308c327caa7be515ce (patch) | |
tree | 4874a53410a25d974075389e7efc623f73508dc6 | |
parent | d77027f49543cbf486a65eb6c845d71929b1e47e (diff) | |
download | ansible-modules-core-653ec28a975182b91a7ef0308c327caa7be515ce.tar.gz |
On Ubuntu16, virtualenv always tries to use python2 even when python2 is not installed.
Workaround that by mimicing the upstream virtualenv behaviour in code
(use the python version that was used to invoke virtualenv/the ansible
module)
-rwxr-xr-x | packaging/language/pip.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packaging/language/pip.py b/packaging/language/pip.py index 405c2308..95cd7caf 100755 --- a/packaging/language/pip.py +++ b/packaging/language/pip.py @@ -79,7 +79,7 @@ options: description: - The Python executable used for creating the virtual environment. For example C(python3.5), C(python2.7). When not specified, the - system Python version is used. + Python version used to run the ansible module is used. required: false default: null state: @@ -415,6 +415,14 @@ def main(): if virtualenv_python: cmd += ' -p%s' % virtualenv_python + elif PY3: + # Ubuntu currently has a patch making virtualenv always + # try to use python2. Since Ubuntu16 works without + # python2 installed, this is a problem. This code mimics + # the upstream behaviour of using the python which invoked + # virtualenv to determine which python is used inside of + # the virtualenv (when none are specified). + cmd += ' -p%s' % sys.executable cmd = "%s %s" % (cmd, env) rc, out_venv, err_venv = module.run_command(cmd, cwd=chdir) |