[stable-2.10] Fix ansible-test virtualenv management.

(cherry picked from commit 1e02a201a6)

Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
Matt Clay 2020-07-13 22:34:34 -07:00
parent ddc78622a4
commit c2b69fd30e
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 path, # type: str
): # type: (...) -> bool ): # type: (...) -> bool
"""Create a virtual environment using the 'virtualenv' module.""" """Create a virtual environment using the 'virtualenv' module."""
cmd = [run_python, '-m', 'virtualenv'] # always specify --python to guarantee the desired interpreter is provided
# otherwise virtualenv may select a different interpreter than the one running virtualenv
if run_python != env_python: cmd = [run_python, '-m', 'virtualenv', '--python', env_python]
cmd += ['--python', env_python]
if system_site_packages: if system_site_packages:
cmd.append('--system-site-packages') cmd.append('--system-site-packages')