mirror of https://github.com/ansible/ansible.git
[stable-2.9] Work around virtualenv/venv issue in ansible-test. (#62111)
Creating a virtual environment using `venv` when running in a virtual environment created by `virtualenv` results in a copy of the original virtual environment instead of creation of a new one.
To work around this, `ansible-test` now identifies when it is running in a `virtualenv` created virtual environment and uses the real Python interpreter to create the `venv` virtual environment.
(cherry picked from commit a7bc11c
)
Co-authored-by: Matt Clay <matt@mystile.com>
pull/62162/head
parent
c2387536ab
commit
d9d8d55861
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- ansible-test now properly creates a virtual environment using ``venv`` when running in a ``virtualenv`` created virtual environment
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Detect the real python interpreter when running in a virtual environment created by the 'virtualenv' module."""
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
try:
|
||||||
|
from sys import real_prefix
|
||||||
|
except ImportError:
|
||||||
|
real_prefix = None
|
||||||
|
|
||||||
|
print(json.dumps(dict(
|
||||||
|
real_prefix=real_prefix,
|
||||||
|
)))
|
Loading…
Reference in New Issue