Debian Codegraph @

test/lib/ansible_test/_util/target/tools/virtualenvcheck.py

raw
1 """Detect the real python interpreter when running in a virtual environment created by the 'virtualenv' module."""
2
3 from __future__ import annotations
4
5 import json
6
7 try:
8 # virtualenv <20
9 from sys import real_prefix # type: ignore[attr-defined]
10 except ImportError:
11 real_prefix = None
12
13 try:
14 # venv and virtualenv >= 20
15 from sys import base_exec_prefix
16 except ImportError:
17 base_exec_prefix = None
18
19 print(json.dumps(dict(
20 real_prefix=real_prefix or base_exec_prefix,
21 )))