Skip to content

Commit f7d2564

Browse files
ayemillerchryslepre-commit-ci[bot]
authored
Fixes #1509 short-circuit of installing packages when already installed (#1510)
Co-authored-by: chrysle <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b109824 commit f7d2564

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

changelog.d/1509.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix installation abortion on multiple packages when one or more are already installed.

src/pipx/commands/install.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def install(
8484
"""
8585
)
8686
)
87-
return EXIT_CODE_INSTALL_VENV_EXISTS
87+
if len(package_specs) == 1:
88+
return EXIT_CODE_INSTALL_VENV_EXISTS
89+
# Reset venv_dir to None ready to install the next package in the list
90+
venv_dir = None
91+
continue
8892

8993
try:
9094
# Enable installing shared library `pip` with `pipx`

tests/test_install.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ def test_install_tricky_packages(capsys, pipx_temp_env, caplog, package_name, pa
8585
install_packages(capsys, pipx_temp_env, caplog, [package_spec], [package_name])
8686

8787

88+
def test_install_multiple_packages_when_some_already_installed(capsys, pipx_temp_env, caplog):
89+
run_pipx_cli(["install", "black", "pycowsay"])
90+
captured = capsys.readouterr()
91+
assert "installed package black" in captured.out
92+
assert "installed package pycowsay" in captured.out
93+
94+
run_pipx_cli(["install", "black", "pycowsay", "isort"])
95+
captured = capsys.readouterr()
96+
assert "'black' already seems to be installed" in captured.out
97+
assert "'pycowsay' already seems to be installed" in captured.out
98+
assert "installed package isort" in captured.out
99+
100+
88101
def test_install_tricky_multiple_packages(capsys, pipx_temp_env, caplog):
89102
if os.getenv("FAST"):
90103
pytest.skip("skipping slow tests")

0 commit comments

Comments
 (0)