From 8469499e9929a666cf902535ca37904c1fab3914 Mon Sep 17 00:00:00 2001 From: Jace Browning Date: Sat, 24 Feb 2018 15:10:59 -0500 Subject: [PATCH] Assume PIPENV_VENV_IN_PROJECT when a local virtual environment exists --- HISTORY.txt | 2 ++ pipenv/environments.py | 2 +- tests/test_pipenv.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.txt b/HISTORY.txt index 3a9c3b7319..8003cf1cc7 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -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. diff --git a/pipenv/environments.py b/pipenv/environments.py index 9aadc56c57..01ff3d37cc 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -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')) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 6e92fed1c0..82f4626302 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -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