Skip to content

Commit

Permalink
do not raise error if package is already installed #125
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Apr 1, 2019
1 parent c0d91fc commit 11b853e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,5 +1,6 @@
0.12.4.0
0.13.0.0
* Add `runpip` command
* Do not raise error when running `pipx install PACKAGE` and the package has already been installed by pipx (#125)

0.12.3.3
* Update logic in determining a package's binaries during installation. This removes spurious binaries from the installation. (#104)
Expand Down
6 changes: 4 additions & 2 deletions pipx/commands.py
Expand Up @@ -298,10 +298,12 @@ def install(
if force:
print(f"Installing to existing directory {str(venv_dir)!r}")
else:
raise PipxError(
f"Not installing to existing directory {str(venv_dir)!r}. "
print(
f"{package!r} already seems to be installed. "
"Not modifying existing installation in {str(venv_dir)!r}. "
"Pass '--force' to force installation"
)
return

venv = Venv(venv_dir, python=python, verbose=verbose)
venv.create_venv(venv_args, pip_args)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pipx.py
Expand Up @@ -166,6 +166,10 @@ def test_editable_install(self):
[self.pipx_bin, "install", "-e", "pipx", "--spec", PIPX_PATH], check=True
)

def test_install_existing_package(self):
subprocess.run([self.pipx_bin, "install", "pycowsay"], check=True)
subprocess.run([self.pipx_bin, "install", "pycowsay"], check=True)

def test_runpip(self):
subprocess.run([self.pipx_bin, "install", "pycowsay"], check=True)
subprocess.run([self.pipx_bin, "runpip", "pycowsay", "list"], check=True)
Expand Down

0 comments on commit 11b853e

Please sign in to comment.