Merge branch 'master' into patch-1

This commit is contained in:
Frost Ming
2020-08-05 15:49:37 +08:00
committed by GitHub
6 changed files with 14 additions and 25 deletions
-3
View File
@@ -1,3 +0,0 @@
PyPA Projects are governed by the PyPA code of conduct available here:
https://www.pypa.io/en/latest/code-of-conduct/
+1 -1
View File
@@ -1,4 +1,4 @@
include LICENSE README.md CONTRIBUTING.md CODE_OF_CONDUCT.md CHANGELOG.rst NOTICES HISTORY.txt
include LICENSE README.md CONTRIBUTING.md CHANGELOG.rst NOTICES HISTORY.txt
include Makefile pyproject.toml get-pipenv.py .dockerignore *.yml
include examples/Pipfil*
include *.md
-2
View File
@@ -20,7 +20,6 @@ trigger:
- '*/vendor.txt'
- 'CHANGELOG.rst'
- 'CONTRIBUTING.md'
- 'CODE_OF_CONDUCT.md'
- '*.md'
- '.gitignore'
- '.gitattributes'
@@ -43,7 +42,6 @@ pr:
- '*/vendor.txt'
- 'CHANGELOG.rst'
- 'CONTRIBUTING.md'
- 'CODE_OF_CONDUCT.md'
- '*.md'
- '.gitignore'
- '.gitattributes'
+1
View File
@@ -0,0 +1 @@
Correctly detect whether Pipenv in run under an activated virtualenv.
+10 -17
View File
@@ -367,16 +367,16 @@ def is_quiet(threshold=-1):
return PIPENV_VERBOSITY <= threshold
def _is_using_venv():
def is_using_venv():
# type: () -> bool
"""Check for venv-based virtual environment which sets sys.base_prefix"""
return sys.prefix != getattr(sys, "base_prefix", sys.prefix)
def _is_using_virtualenv():
# type: () -> bool
"""Check for virtualenv-based environment which sets sys.real_prefix"""
return getattr(sys, "real_prefix", None) is not None
if getattr(sys, 'real_prefix', None) is not None:
# virtualenv venvs
result = True
else:
# PEP 405 venvs
result = sys.prefix != getattr(sys, 'base_prefix', sys.prefix)
return result
def is_in_virtualenv():
@@ -388,16 +388,9 @@ def is_in_virtualenv():
"""
pipenv_active = os.environ.get("PIPENV_ACTIVE", False)
virtual_env = None
use_system = False
virtual_env = bool(os.environ.get("VIRTUAL_ENV"))
ignore_virtualenvs = bool(os.environ.get("PIPENV_IGNORE_VIRTUALENVS", False))
if not pipenv_active and not ignore_virtualenvs:
virtual_env = any([
_is_using_virtualenv(), _is_using_venv(), os.environ.get("VIRTUAL_ENV")
])
use_system = bool(virtual_env)
return (use_system or virtual_env) and not (pipenv_active or ignore_virtualenvs)
return virtual_env and not (pipenv_active or ignore_virtualenvs)
PIPENV_SPINNER_FAIL_TEXT = fix_utf8(u"{0}") if not PIPENV_HIDE_EMOJIS else ("{0}")
+2 -2
View File
@@ -25,7 +25,7 @@ from .environment import Environment
from .environments import (
PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_IGNORE_VIRTUALENVS, PIPENV_MAX_DEPTH,
PIPENV_PIPFILE, PIPENV_PYTHON, PIPENV_TEST_INDEX, PIPENV_VENV_IN_PROJECT,
PIPENV_USE_SYSTEM, is_in_virtualenv, is_type_checking
PIPENV_USE_SYSTEM, is_in_virtualenv, is_type_checking, is_using_venv
)
from .vendor.requirementslib.models.utils import get_default_pyproject_backend
from .utils import (
@@ -349,7 +349,7 @@ class Project(object):
def get_environment(self, allow_global=False):
# type: (bool) -> Environment
is_venv = is_in_virtualenv()
is_venv = is_in_virtualenv() or is_using_venv()
if allow_global and not is_venv:
prefix = sys.prefix
python = sys.executable