Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort pipenv when pip install fails #3319

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]