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

Fix combining of --editable and --force flag #1124

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ docs/docs.md
pipx.1
.pipx_tests
/.coverage*
testdata
/testdata
!/testdata/empty_project
/.idea
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## dev

- Fix combining of --editable and --force flag

## 1.3.0

- Check whether pip module exists in shared lib before performing any actions, such as `reinstall-all`.
Expand Down
2 changes: 1 addition & 1 deletion src/pipx/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def install(
)
if force:
print(f"Installing to existing venv {venv.name!r}")
pip_args += ["--force-reinstall"]
pip_args = ["--force-reinstall"] + pip_args
else:
print(
pipx_wrap(
Expand Down
1 change: 1 addition & 0 deletions testdata/empty_project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Empty project used for testing only
Empty file.
6 changes: 6 additions & 0 deletions testdata/empty_project/empty_project/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
pass


if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions testdata/empty_project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[build-system]
requires = [
"setuptools",
"wheel",
]

[project]
name = "empty-project"
version = "0.1.0"
description = "Empty Python Project"
authors = [{ name = "My Name", email = "[email protected]" }]
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
scripts.empty-project = "empty_project.main:cli"
13 changes: 13 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

TEST_DATA_PATH = "./testdata/test_package_specifier"

SOURCE_DIR = Path(__file__).parent.parent.resolve()
potiuk marked this conversation as resolved.
Show resolved Hide resolved


def test_help_text(monkeypatch, capsys):
mock_exit = mock.Mock(side_effect=ValueError("raised in test to exit early"))
Expand Down Expand Up @@ -285,6 +287,17 @@ def test_force_install_changes(pipx_temp_env, capsys):
assert "2022.1.7" not in captured.out


def test_force_install_changes_editable(pipx_temp_env, capsys):
empty_project_path_as_string = (SOURCE_DIR / "testdata" / "empty_project").as_posix()
assert not run_pipx_cli(["install", "--editable", empty_project_path_as_string])
captured = capsys.readouterr()
assert "empty-project" in captured.out

assert not run_pipx_cli(["install", "--editable", empty_project_path_as_string, "--force"])
captured = capsys.readouterr()
assert "Installing to existing venv 'empty-project'" in captured.out


def test_preinstall(pipx_temp_env, caplog):
assert not run_pipx_cli(["install", "--preinstall", "black", "nox"])
assert "black" in caplog.text
Expand Down
Loading