Skip to content

Commit

Permalink
add preinstall with multiple packages example, cli help and test (#1321)
Browse files Browse the repository at this point in the history
* add preinstall with multiple packages Example

* extend cli help and add test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* better test packges

* add changelog entry

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
gempir and pre-commit-ci[bot] authored Apr 3, 2024
1 parent f8e7bfc commit e6d85f8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1321.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add example, test and cli help description how to install multiple packages with the --preinstall flag
1 change: 1 addition & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pipx install git+https://github.com/psf/black.git@git-hash
pipx install git+ssh://<username>@<private-repo-domain>/<path-to-package.git>
pipx install https://github.com/psf/black/archive/18.9b0.zip
pipx install black[d]
pipx install --preinstall ansible-lint --preinstall mitogen ansible-core
pipx install 'black[d] @ git+https://github.com/psf/black.git@branch-name'
pipx install --suffix @branch-name 'black[d] @ git+https://github.com/psf/black.git@branch-name'
pipx install --include-deps jupyter
Expand Down
5 changes: 4 additions & 1 deletion src/pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ def _add_install(subparsers: argparse._SubParsersAction, shared_parser: argparse
p.add_argument(
"--preinstall",
action="append",
help=("Optional packages to be installed into the Virtual Environment before " "installing the main package."),
help=(
"Optional package to be installed into the Virtual Environment before "
"installing the main package. Use this flag multiple times if you want to preinstall multiple packages."
),
)
add_pip_venv_args(p)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ def test_preinstall(pipx_temp_env, caplog):
assert "black" in caplog.text


def test_preinstall_multiple(pipx_temp_env, caplog):
assert not run_pipx_cli(["install", "--preinstall", "chardet", "--preinstall", "colorama", "nox"])
assert "chardet" in caplog.text
assert "colorama" in caplog.text


@pytest.mark.xfail
def test_do_not_wait_for_input(pipx_temp_env, pipx_session_shared_dir, monkeypatch):
monkeypatch.setenv("PIP_INDEX_URL", "http://127.0.0.1:8080/simple")
Expand Down

0 comments on commit e6d85f8

Please sign in to comment.