determin virtualenv location on the run

Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
Frost Ming
2018-11-17 17:51:26 +08:00
parent df924d3ea3
commit a8f52eb0a6
2 changed files with 4 additions and 1 deletions
+3 -1
View File
@@ -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.
+1
View File
@@ -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")