Skip to content

Commit

Permalink
pipx inject: Imply --include-apps if --include-deps is passed (#…
Browse files Browse the repository at this point in the history
…984)

Co-authored-by: Bernát Gábor <[email protected]>
  • Loading branch information
chrysle and gaborbernat authored Nov 30, 2023
1 parent d4798ea commit 1508f18
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## dev

- Imply `--include-apps` when running `pipx inject --include-deps`
- Add `--with-suffix` for `pipx inject` command
- `pipx install`: emit a warning when `--force` and `--python` were passed at the same time
- Drop support for Python 3.7
Expand Down
4 changes: 1 addition & 3 deletions src/pipx/commands/inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ def inject(
) -> ExitCode:
"""Returns pipx exit code."""
if not include_apps and include_dependencies:
raise PipxError(
"Cannot pass --include-deps if --include-apps is not passed as well"
)
include_apps = True
all_success = True
for dep in package_specs:
all_success &= inject_dep(
Expand Down
6 changes: 5 additions & 1 deletion src/pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ def _add_inject(subparsers, venv_completer: VenvCompleter) -> None:
action="store_true",
help="Add apps from the injected packages onto your PATH",
)
add_include_dependencies(p)
p.add_argument(
"--include-deps",
help="Include apps of dependent packages. Implies --include-apps",
action="store_true",
)
add_pip_venv_args(p)
p.add_argument(
"--force",
Expand Down
18 changes: 3 additions & 15 deletions tests/test_inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,15 @@ def test_inject_include_apps(pipx_temp_env, capsys, with_suffix):
install_args = [f"--suffix={suffix}"]

assert not run_pipx_cli(["install", "pycowsay", *install_args])
assert run_pipx_cli(
assert not run_pipx_cli(
["inject", f"pycowsay{suffix}", PKG["black"]["spec"], "--include-deps"]
)

if suffix:
assert run_pipx_cli(
[
"inject",
"pycowsay",
PKG["black"]["spec"],
"--include-deps",
"--include-apps",
]
["inject", "pycowsay", PKG["black"]["spec"], "--include-deps"]
)

assert not run_pipx_cli(
[
"inject",
f"pycowsay{suffix}",
PKG["black"]["spec"],
"--include-deps",
"--include-apps",
]
["inject", f"pycowsay{suffix}", PKG["black"]["spec"], "--include-deps"]
)

0 comments on commit 1508f18

Please sign in to comment.