Skip to content

Commit

Permalink
Addresses ansible#4735 Verify the virtualenv command supports --no-si…
Browse files Browse the repository at this point in the history
…te-packages before passing it
  • Loading branch information
jctanner committed Nov 5, 2013
1 parent 9aa93fa commit 65d68bb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion library/packaging/pip
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ EXAMPLES = '''
- pip: name=bottle executable=pip-3.3
'''

def _get_cmd_options(module, cmd):
thiscmd = cmd + " --help"
rc, stdout, stderr = module.run_command(thiscmd)
#import epdb; epdb.serve()
if rc != 0:
module.fail_json(msg="Could not get --help output from %s" % virtualenv)

words = stdout.strip().split()
cmd_options = [ x for x in words if x.startswith('--') ]
return cmd_options


def _get_full_name(name, version=None):
if version is None:
Expand Down Expand Up @@ -247,7 +258,11 @@ def main():
if module.params['virtualenv_site_packages']:
cmd = '%s --system-site-packages %s' % (virtualenv, env)
else:
cmd = '%s --no-site-packages %s' % (virtualenv, env)
cmd_opts = _get_cmd_options(module, virtualenv)
if '--no-site-packages' in cmd_opts:
cmd = '%s --no-site-packages %s' % (virtualenv, env)
else:
cmd = '%s %s' % (virtualenv, env)
os.chdir(tempfile.gettempdir())
if chdir:
os.chdir(chdir)
Expand Down

0 comments on commit 65d68bb

Please sign in to comment.