ansible-test - Fix Python real prefix detection.

This commit is contained in:
Matt Clay
2021-10-21 15:28:48 -07:00
parent 0bf7b3f4ef
commit b4cbe1adcf
2 changed files with 15 additions and 1 deletions
@@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix Python real prefix detection when running in a ``venv`` virtual environment.
@@ -5,10 +5,22 @@ __metaclass__ = type
import json
try:
# virtualenv <20
from sys import real_prefix
except ImportError:
real_prefix = None
try:
# venv and virtualenv >= 20
from sys import base_exec_prefix
except ImportError:
base_exec_prefix = None
try:
from sys import base_exec_prefix
except ImportError:
base_exec_prefix = None
print(json.dumps(dict(
real_prefix=real_prefix,
real_prefix=real_prefix or base_exec_prefix,
)))