summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2016-10-20 13:09:58 -0700
committerMichael Scherer <mscherer@users.noreply.github.com>2016-10-20 22:17:36 +0200
commit653ec28a975182b91a7ef0308c327caa7be515ce (patch)
tree4874a53410a25d974075389e7efc623f73508dc6
parentd77027f49543cbf486a65eb6c845d71929b1e47e (diff)
downloadansible-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-xpackaging/language/pip.py10
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)