From 52d21c05f47dedc4e965f6c97c900f3343e0796f Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Wed, 6 Dec 2017 20:22:59 -0500 Subject: [PATCH] Exclude dev packages from installs by default - Fixes #1172 - Regression introduced in 6e7dd14 - Add test to prevent future regressions - Update history --- HISTORY.txt | 1 + pipenv/utils.py | 2 ++ tests/test_pipenv.py | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/HISTORY.txt b/HISTORY.txt index 973d9f48..97426f9a 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,3 +1,4 @@ + - Fixed regression causing development packages to always be installed 9.0.0: - Fixed bug where packages beginning with vcs names (e.g. git) weren't installed correctly. - Fixed url parsing for +:// style urls. diff --git a/pipenv/utils.py b/pipenv/utils.py index 52fec9e7..50ba449e 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -998,6 +998,8 @@ def merge_deps(file_dict, project, dev=False, requirements=False, ignore_hashes= if not file_dict[section] or section_name not in ('dev-packages', 'packages', 'default', 'develop'): continue is_dev = section_name in ('dev-packages', 'develop') + if is_dev and not dev: + continue if ignore_hashes: for k, v in file_dict[section]: diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 66d06d3e..bd716c71 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -243,6 +243,32 @@ class TestPipenv: c = p.pipenv('run python -m requests.help') assert c.return_code == 0 + @pytest.mark.dev + @pytest.mark.install + def test_install_without_dev(self): + """Ensure that running `pipenv install` doesn't install dev packages""" + with PipenvInstance() as p: + with open(p.pipfile_path, 'w') as f: + contents = """ +[packages] +tablib = "*" + +[dev-packages] +records = "*" + """.strip() + f.write(contents) + c = p.pipenv('install') + assert c.return_code == 0 + assert 'tablib' in p.pipfile['packages'] + assert 'records' in p.pipfile['dev-packages'] + assert 'tablib' in p.lockfile['default'] + assert 'records' in p.lockfile['develop'] + c = p.pipenv('run python -c "import records"') + assert c.return_code != 0 + c = p.pipenv('run python -c "import tablib"') + assert c.return_code == 0 + + @pytest.mark.run @pytest.mark.uninstall def test_uninstall(self):