Skip to content

Commit

Permalink
Merge pull request #3319 from pypa/bugfix/3318
Browse files Browse the repository at this point in the history
Abort pipenv when pip install fails
  • Loading branch information
frostming authored Nov 28, 2018
2 parents 55057a8 + 6873145 commit f4c325c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/3318.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Abort pipenv before adding the non-exist package to Pipfile.
3 changes: 3 additions & 0 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1926,13 +1926,16 @@ def do_install(
extra_indexes=extra_index_url,
pypi_mirror=pypi_mirror,
)
if not c.ok:
raise RuntimeError(c.err)
except (ValueError, RuntimeError) as e:
sp.write_err(vistir.compat.fs_str(
"{0}: {1}".format(crayons.red("WARNING"), e),
))
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(
"Installation Failed",
))
sys.exit(1)
# Warn if --editable wasn't passed.
if pkg_requirement.is_vcs and not pkg_requirement.editable:
sp.write_err(
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,11 @@ def test_install_creates_pipfile(PipenvInstance):
c = p.pipenv("install")
assert c.return_code == 0
assert os.path.isfile(p.pipfile_path)


@pytest.mark.install
def test_install_non_exist_dep(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv("install dateutil")
assert not c.ok
assert "dateutil" not in p.pipfile["packages"]

0 comments on commit f4c325c

Please sign in to comment.