Skip to content

Commit

Permalink
Stop using PYVENV_LAUNCHER env variable when detecting venvs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nstapelbroek committed Jun 4, 2020
1 parent f1ad3f5 commit 6b437a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/4316.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix falsely flagging a Homebrew installed Python as a virtual environment
6 changes: 3 additions & 3 deletions pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 6b437a6

Please sign in to comment.