Skip to content

Commit e6d85f8

Browse files
add preinstall with multiple packages example, cli help and test (#1321)
* 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>
1 parent f8e7bfc commit e6d85f8

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

changelog.d/1321.doc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add example, test and cli help description how to install multiple packages with the --preinstall flag

docs/examples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pipx install git+https://github.com/psf/black.git@git-hash
1111
pipx install git+ssh://<username>@<private-repo-domain>/<path-to-package.git>
1212
pipx install https://github.com/psf/black/archive/18.9b0.zip
1313
pipx install black[d]
14+
pipx install --preinstall ansible-lint --preinstall mitogen ansible-core
1415
pipx install 'black[d] @ git+https://github.com/psf/black.git@branch-name'
1516
pipx install --suffix @branch-name 'black[d] @ git+https://github.com/psf/black.git@branch-name'
1617
pipx install --include-deps jupyter

src/pipx/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,10 @@ def _add_install(subparsers: argparse._SubParsersAction, shared_parser: argparse
426426
p.add_argument(
427427
"--preinstall",
428428
action="append",
429-
help=("Optional packages to be installed into the Virtual Environment before " "installing the main package."),
429+
help=(
430+
"Optional package to be installed into the Virtual Environment before "
431+
"installing the main package. Use this flag multiple times if you want to preinstall multiple packages."
432+
),
430433
)
431434
add_pip_venv_args(p)
432435

tests/test_install.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ def test_preinstall(pipx_temp_env, caplog):
338338
assert "black" in caplog.text
339339

340340

341+
def test_preinstall_multiple(pipx_temp_env, caplog):
342+
assert not run_pipx_cli(["install", "--preinstall", "chardet", "--preinstall", "colorama", "nox"])
343+
assert "chardet" in caplog.text
344+
assert "colorama" in caplog.text
345+
346+
341347
@pytest.mark.xfail
342348
def test_do_not_wait_for_input(pipx_temp_env, pipx_session_shared_dir, monkeypatch):
343349
monkeypatch.setenv("PIP_INDEX_URL", "http://127.0.0.1:8080/simple")

0 commit comments

Comments
 (0)