Skip to content

Commit

Permalink
Fixes #1509 short-circuit of installing packages when already install…
Browse files Browse the repository at this point in the history
…ed (#1510)

Co-authored-by: chrysle <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent b109824 commit f7d2564
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1509.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix installation abortion on multiple packages when one or more are already installed.
6 changes: 5 additions & 1 deletion src/pipx/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ def install(
"""
)
)
return EXIT_CODE_INSTALL_VENV_EXISTS
if len(package_specs) == 1:
return EXIT_CODE_INSTALL_VENV_EXISTS
# Reset venv_dir to None ready to install the next package in the list
venv_dir = None
continue

try:
# Enable installing shared library `pip` with `pipx`
Expand Down
13 changes: 13 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ def test_install_tricky_packages(capsys, pipx_temp_env, caplog, package_name, pa
install_packages(capsys, pipx_temp_env, caplog, [package_spec], [package_name])


def test_install_multiple_packages_when_some_already_installed(capsys, pipx_temp_env, caplog):
run_pipx_cli(["install", "black", "pycowsay"])
captured = capsys.readouterr()
assert "installed package black" in captured.out
assert "installed package pycowsay" in captured.out

run_pipx_cli(["install", "black", "pycowsay", "isort"])
captured = capsys.readouterr()
assert "'black' already seems to be installed" in captured.out
assert "'pycowsay' already seems to be installed" in captured.out
assert "installed package isort" in captured.out


def test_install_tricky_multiple_packages(capsys, pipx_temp_env, caplog):
if os.getenv("FAST"):
pytest.skip("skipping slow tests")
Expand Down

0 comments on commit f7d2564

Please sign in to comment.