From 6b437a6140c06f11101156e2b8ee45a6e66aa161 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Wed, 3 Jun 2020 22:28:27 +0200 Subject: [PATCH] Stop using PYVENV_LAUNCHER env variable when detecting venvs This seems to lead to false positives as every Homebrew installed Python has this environment variable set. The original comment hints to a workaround so I'd figured we should not give it extra responsibilities. Fixes #4316 --- news/4316.bugfix.rst | 1 + pipenv/environments.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 news/4316.bugfix.rst diff --git a/news/4316.bugfix.rst b/news/4316.bugfix.rst new file mode 100644 index 0000000000..66d4584007 --- /dev/null +++ b/news/4316.bugfix.rst @@ -0,0 +1 @@ +Fix falsely flagging a Homebrew installed Python as a virtual environment diff --git a/pipenv/environments.py b/pipenv/environments.py index 005d0a2d32..d98e36ad92 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -81,7 +81,7 @@ def get_from_env(arg, prefix="PIPENV", check_for_negation=True): # HACK: Prevent invalid shebangs with Homebrew-installed Python: # https://bugs.python.org/issue22490 -_OSX_VENV = os.environ.pop("__PYVENV_LAUNCHER__", None) +os.environ.pop("__PYVENV_LAUNCHER__", None) # Load patched pip instead of system pip os.environ["PIP_SHIMS_BASE_MODULE"] = fs_str("pipenv.patched.notpip") @@ -326,7 +326,7 @@ def get_from_env(arg, prefix="PIPENV", check_for_negation=True): PIPENV_USE_SYSTEM = False PIPENV_VIRTUALENV = None if "PIPENV_ACTIVE" not in os.environ and not PIPENV_IGNORE_VIRTUALENVS: - PIPENV_VIRTUALENV = os.environ.get("VIRTUAL_ENV") or _OSX_VENV + PIPENV_VIRTUALENV = os.environ.get("VIRTUAL_ENV") PIPENV_USE_SYSTEM = bool(PIPENV_VIRTUALENV) # Internal, tells Pipenv to skip case-checking (slow internet connections). @@ -370,7 +370,7 @@ def is_quiet(threshold=-1): def _is_using_venv(): # type: () -> bool """Check for venv-based virtual environment which sets sys.base_prefix""" - return _OSX_VENV is not None or sys.prefix != getattr(sys, "base_prefix", sys.prefix) + return sys.prefix != getattr(sys, "base_prefix", sys.prefix) def _is_using_virtualenv():