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

Fixes #1509 short-circuit of installing packages when already installed #1510

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 changelog.d/1509.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Installs multiple packages regardless if one or more already installed.
ayemiller marked this conversation as resolved.
Show resolved Hide resolved
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
chrysle marked this conversation as resolved.
Show resolved Hide resolved
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