Fix ansible-test virtualenv management.

This commit is contained in:
Matt Clay 2020-07-13 22:34:34 -07:00
parent 09f02980a4
commit 1e02a201a6
2 changed files with 5 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ansible-test now always uses the ``--python`` option for ``virtualenv`` to select the correct interpreter when creating environments with the ``--venv`` option

View file

@ -173,10 +173,9 @@ def run_virtualenv(args, # type: EnvironmentConfig
path, # type: str
): # type: (...) -> bool
"""Create a virtual environment using the 'virtualenv' module."""
cmd = [run_python, '-m', 'virtualenv']
if run_python != env_python:
cmd += ['--python', env_python]
# always specify --python to guarantee the desired interpreter is provided
# otherwise virtualenv may select a different interpreter than the one running virtualenv
cmd = [run_python, '-m', 'virtualenv', '--python', env_python]
if system_site_packages:
cmd.append('--system-site-packages')