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

Add --force-reinstall to pip args when --force was passed #933

Merged
merged 4 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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()`
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/pipx/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading