mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Addresses #4735 Verify the virtualenv command supports --no-site-packages before passing it
This commit is contained in:
parent
9aa93fa307
commit
65d68bb1b4
1 changed files with 16 additions and 1 deletions
|
@ -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:
|
||||
|
@ -247,7 +258,11 @@ def main():
|
|||
if module.params['virtualenv_site_packages']:
|
||||
cmd = '%s --system-site-packages %s' % (virtualenv, env)
|
||||
else:
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue