Merge pull request #4413 from jerm/ansible
Add capability to pass in a PATH prefix to run_command and allow pip module to utilize that to make virtualenv bin/ available in pip installs
This commit is contained in:
commit
3b1854c5b2
1 changed files with 11 additions and 1 deletions
|
@ -275,6 +275,16 @@ def main():
|
||||||
pip = _get_pip(module, env, module.params['executable'])
|
pip = _get_pip(module, env, module.params['executable'])
|
||||||
|
|
||||||
cmd = '%s %s' % (pip, state_map[state])
|
cmd = '%s %s' % (pip, state_map[state])
|
||||||
|
|
||||||
|
# If there's a virtualenv we want things we install to be able to use other
|
||||||
|
# installations that exist as binaries within this virtualenv. Example: we
|
||||||
|
# install cython and then gevent -- gevent needs to use the cython binary,
|
||||||
|
# not just a python package that will be found by calling the right python.
|
||||||
|
# So if there's a virtualenv, we add that bin/ to the beginning of the PATH
|
||||||
|
# in run_command by setting path_prefix here.
|
||||||
|
path_prefix = None
|
||||||
|
if env:
|
||||||
|
path_prefix="/".join(pip.split('/')[:-1])
|
||||||
|
|
||||||
if extra_args:
|
if extra_args:
|
||||||
cmd += ' %s' % extra_args
|
cmd += ' %s' % extra_args
|
||||||
|
@ -320,7 +330,7 @@ def main():
|
||||||
os.chdir(tempfile.gettempdir())
|
os.chdir(tempfile.gettempdir())
|
||||||
if chdir:
|
if chdir:
|
||||||
os.chdir(chdir)
|
os.chdir(chdir)
|
||||||
rc, out_pip, err_pip = module.run_command(cmd)
|
rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix)
|
||||||
out += out_pip
|
out += out_pip
|
||||||
err += err_pip
|
err += err_pip
|
||||||
if rc == 1 and state == 'absent' and 'not installed' in out_pip:
|
if rc == 1 and state == 'absent' and 'not installed' in out_pip:
|
||||||
|
|
Loading…
Reference in a new issue