ansible/test/lib/ansible_test/_data/virtualenvcheck.py
Matt Clay a7bc11ce67
Work around virtualenv/venv issue in ansible-test. ()
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.
2019-09-10 19:27:12 -07:00

16 lines
386 B
Python
Executable file

#!/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,
)))