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 preinstall with multiple packages example, cli help and test #1321

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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