Skip to content

Commit

Permalink
Merge pull request #1492 from jacebrowning/reuse-previous-venv
Browse files Browse the repository at this point in the history
Assume PIPENV_VENV_IN_PROJECT when a local virtual environment exists
  • Loading branch information
kennethreitz authored Feb 25, 2018
2 parents 8a2eba0 + 8469499 commit 9089422
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
next:
- Assume `PIPENV_VENV_IN_PROJECT` if `./.venv/` already exists.
10.1.0:
- Default dependencies now take precidence over Develop dependencies when
creating a Pipfile.lock.
Expand Down
2 changes: 1 addition & 1 deletion pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PIPENV_SHELL_FANCY = bool(os.environ.get('PIPENV_SHELL_FANCY'))

# Create the virtualenv in the project, instead of with pew.
PIPENV_VENV_IN_PROJECT = bool(os.environ.get('PIPENV_VENV_IN_PROJECT'))
PIPENV_VENV_IN_PROJECT = bool(os.environ.get('PIPENV_VENV_IN_PROJECT')) or os.path.isdir('.venv')

# No color mode, for unfun people.
PIPENV_COLORBLIND = bool(os.environ.get('PIPENV_COLORBLIND'))
Expand Down
9 changes: 9 additions & 0 deletions tests/test_pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,15 @@ def test_venv_in_project(self):

assert normalize_drive(p.path) in p.pipenv('--venv').out

@pytest.mark.dotvenv
def test_reuse_previous_venv(self):
with PipenvInstance(chdir=True) as p:
os.mkdir('.venv')
c = p.pipenv('install requests')
assert c.return_code == 0

assert normalize_drive(p.path) in p.pipenv('--venv').out

@pytest.mark.dotvenv
@pytest.mark.install
@pytest.mark.complex
Expand Down

0 comments on commit 9089422

Please sign in to comment.