diff --git a/pipenv/project.py b/pipenv/project.py index f3a11f69..b2da4fd2 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -46,6 +46,7 @@ from .environments import ( PIPENV_TEST_INDEX, PIPENV_PYTHON, PIPENV_DEFAULT_PYTHON_VERSION, + PIPENV_IGNORE_VIRTUALENVS, is_in_virtualenv ) @@ -427,7 +428,8 @@ class Project(object): def virtualenv_location(self): # if VIRTUAL_ENV is set, use that. virtualenv_env = os.getenv("VIRTUAL_ENV") - if virtualenv_env: + if ("PIPENV_ACTIVE" not in os.environ and + not PIPENV_IGNORE_VIRTUALENVS and virtualenv_env): return virtualenv_env if not self._virtualenv_location: # Use cached version, if available. diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index f4951886..8bb76da1 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -185,6 +185,7 @@ def test_include_editable_packages(PipenvInstance, pypi, testsroot, pathlib_tmpd @pytest.mark.project def test_run_in_virtualenv(PipenvInstance, pypi, virtualenv): with PipenvInstance(chdir=True, pypi=pypi) as p: + os.environ.pop("PIPENV_IGNORE_VIRTUALENVS", None) project = Project() assert project.virtualenv_location == str(virtualenv) c = p.pipenv("run pip install click")