def _running_under_venv():
    # type: () -> bool
    """Checks if sys.base_prefix and sys.prefix match.

    This handles PEP 405 compliant virtual environments.
    """
    return sys.prefix != getattr(sys, "base_prefix", sys.prefix)
Checks if sys.base_prefix and sys.prefix match.

    This handles PEP 405 compliant virtual environments.
    
product/gradle-plugin/src/main/python/pip/_internal/utils/virtualenv.py