mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
determin virtualenv location on the run
Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
+3
-1
@@ -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.
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user