mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Correct the virtualenv location passed to environment
Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
+1
-4
@@ -1566,10 +1566,7 @@ def format_pip_output(out, r=None):
|
||||
|
||||
def warn_in_virtualenv():
|
||||
# Only warn if pipenv isn't already active.
|
||||
pipenv_active = os.environ.get("PIPENV_ACTIVE")
|
||||
if (environments.PIPENV_USE_SYSTEM or environments.PIPENV_VIRTUALENV) and not (
|
||||
pipenv_active or environments.is_quiet()
|
||||
):
|
||||
if environments.is_in_virtualenv() and not environments.is_quiet():
|
||||
click.echo(
|
||||
"{0}: Pipenv found itself running within a virtual environment, "
|
||||
"so it will automatically use that environment, instead of "
|
||||
|
||||
@@ -30,7 +30,7 @@ class Environment(object):
|
||||
self._modules = {'pkg_resources': pkg_resources, 'pipenv': pipenv}
|
||||
self.base_working_set = base_working_set if base_working_set else BASE_WORKING_SET
|
||||
prefix = normalize_path(prefix)
|
||||
self.is_venv = not prefix == normalize_path(sys.prefix)
|
||||
self.is_venv = is_venv or prefix != normalize_path(sys.prefix)
|
||||
if not sources:
|
||||
sources = []
|
||||
self.project = project
|
||||
|
||||
@@ -276,6 +276,11 @@ def is_quiet(threshold=-1):
|
||||
return PIPENV_VERBOSITY <= threshold
|
||||
|
||||
|
||||
def is_in_virtualenv():
|
||||
pipenv_active = os.environ.get("PIPENV_ACTIVE")
|
||||
return (PIPENV_USE_SYSTEM or PIPENV_VIRTUALENV) and not pipenv_active
|
||||
|
||||
|
||||
PIPENV_SPINNER_FAIL_TEXT = fix_utf8(u"✘ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")
|
||||
|
||||
PIPENV_SPINNER_OK_TEXT = fix_utf8(u"✔ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")
|
||||
|
||||
+3
-2
@@ -47,6 +47,7 @@ from .environments import (
|
||||
PIPENV_TEST_INDEX,
|
||||
PIPENV_PYTHON,
|
||||
PIPENV_DEFAULT_PYTHON_VERSION,
|
||||
is_in_virtualenv
|
||||
)
|
||||
|
||||
|
||||
@@ -345,8 +346,8 @@ class Project(object):
|
||||
@property
|
||||
def environment(self):
|
||||
if not self._environment:
|
||||
prefix = self.get_location_for_virtualenv()
|
||||
is_venv = prefix == sys.prefix
|
||||
prefix = self.virtualenv_location
|
||||
is_venv = is_in_virtualenv()
|
||||
sources = self.sources if self.sources else [DEFAULT_SOURCE,]
|
||||
self._environment = Environment(
|
||||
prefix=prefix, is_venv=is_venv, sources=sources, pipfile=self.parsed_pipfile,
|
||||
|
||||
Reference in New Issue
Block a user