diff --git a/CHANGELOG.md b/CHANGELOG.md index 728002218d..5763c64127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## dev +- Add `--force-reinstall` to pip arguments when `--force` was passed - Use the py launcher, if available, to select Python version with the `--python` option - Support including requirements in scripts run using `pipx run` (#916) - Pass `pip_args` to `shared_libs.upgrade()` @@ -16,7 +17,6 @@ - [docs] Add an example for installation from source with extras - Match pip's behaviour when package name ends with archive extension (treat it as a path) - Ship a [zipapp](https://docs.python.org/3/library/zipapp.html) of pipx - - Change the program name to `path/to/python -m pipx` when running as `python -m pipx` - Improve the detection logic for MSYS2 to avoid entering infinite loop (#908) (#938) - Remove extra trailing quote from exception message diff --git a/src/pipx/commands/install.py b/src/pipx/commands/install.py index a7bd8f3d6b..d10cd69feb 100644 --- a/src/pipx/commands/install.py +++ b/src/pipx/commands/install.py @@ -43,6 +43,7 @@ def install( if exists: if force: print(f"Installing to existing venv {venv.name!r}") + pip_args += ["--force-reinstall"] else: print( pipx_wrap( diff --git a/tests/test_install.py b/tests/test_install.py index 27987ee9d1..6cc7f69ce6 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -261,3 +261,15 @@ def test_install_local_archive(pipx_temp_env, monkeypatch, capsys): assert not run_pipx_cli(["install", "repeatme-0.1-py3-none-any.whl"]) captured = capsys.readouterr() assert f"- {app_name('repeatme')}\n" in captured.out + + +def test_force_install_changes(pipx_temp_env, capsys): + assert not run_pipx_cli( + ["install", "https://github.com/wntrblm/nox/archive/2022.1.7.zip"] + ) + captured = capsys.readouterr() + assert "2022.1.7" in captured.out + + assert not run_pipx_cli(["install", "nox", "--force"]) + captured = capsys.readouterr() + assert "2022.1.7" not in captured.out