Skip to content

Commit 809dffe

Browse files
committed
Add docs
1 parent ba641f4 commit 809dffe

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

docs/backend.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Starting from version 1.8.0, pipx supports different backends and installers.
2+
3+
### Backends supported:
4+
- `venv` (Default)
5+
- `uv` (via `uv venv`)
6+
- `virtualenv`
7+
8+
### Installers supported:
9+
- `pip` (Default)
10+
- `uv` (via `uv pip`)
11+
12+
If you wish to use a different backend or installer, you can either:
13+
14+
- Pass command line arguments (`--backend`, `--installer`)
15+
- Set envirionment variables (`PIPX_DEFAULT_BACKEND`, `PIPX_DEFAULT_INSTALLER`)
16+
17+
> [!NOTE]
18+
> Command line arguments always have higher precedence than environment variables.
19+
20+
### Examples
21+
```bash
22+
# Use uv as backend and installer
23+
pipx install --backend uv --installer uv black
24+
25+
# Use virtualenv as backend and uv as installer
26+
pipx install --backend virtualenv --installer uv black
27+
```
28+
29+
Use environment variables to set backend and installer:
30+
```bash
31+
export PIPX_DEFAULT_BACKEND=uv
32+
export PIPX_DEFAULT_INSTALLER=uv
33+
pipx install black
34+
```

docs/examples.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pipx install --index-url https://test.pypi.org/simple/ --pip-args='--extra-index
2121
pipx --global install pycowsay
2222
pipx install .
2323
pipx install path/to/some-project
24+
pipx install --backend uv --installer uv black
2425
```
2526

2627
## `pipx run` examples
@@ -41,6 +42,7 @@ pipx run pycowsay --version # prints pycowsay version
4142
pipx run --python pythonX pycowsay
4243
pipx run pycowsay==2.0 --version
4344
pipx run pycowsay[dev] --version
45+
pipx run --backend uv --installer uv pycowsay
4446
pipx run --spec git+https://github.com/psf/black.git black
4547
pipx run --spec git+https://github.com/psf/black.git@branch-name black
4648
pipx run --spec git+https://github.com/psf/black.git@git-hash black

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ nav:
3131
- Getting Started: "getting-started.md"
3232
- Docs: "docs.md"
3333
- Troubleshooting: "troubleshooting.md"
34+
- Backend: "backend.md"
3435
- Examples: "examples.md"
3536
- Comparison to Other Tools: "comparisons.md"
3637
- How pipx works: "how-pipx-works.md"

tests/test_backend.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22

3-
from helpers import run_pipx_cli
4-
from package_info import _exe_if_win
3+
from helpers import run_pipx_cli, WIN
54

65

76
def test_custom_backend_venv(pipx_temp_env, capsys, caplog):
@@ -14,14 +13,14 @@ def test_custom_backend_venv(pipx_temp_env, capsys, caplog):
1413
def test_custom_backend_virtualenv(pipx_temp_env, capsys, caplog):
1514
assert not run_pipx_cli(["install", "--backend", "virtualenv", "nox"])
1615
captured = capsys.readouterr()
17-
assert f"{_exe_if_win("virtualenv")} --python" in caplog.text
16+
assert "virtualenv" in caplog.text
1817
assert "installed package" in captured.out
1918

2019

2120
def test_custom_backend_uv(pipx_temp_env, capsys, caplog):
2221
assert not run_pipx_cli(["install", "--backend", "uv", "pylint"])
2322
captured = capsys.readouterr()
24-
assert f"{_exe_if_win("uv")} venv" in caplog.text
23+
assert "uv" in caplog.text
2524
assert "installed package" in captured.out
2625

2726

@@ -35,38 +34,38 @@ def test_custom_installer_pip(pipx_temp_env, capsys, caplog):
3534
def test_custom_installer_uv(pipx_temp_env, capsys, caplog):
3635
assert not run_pipx_cli(["install", "--installer", "uv", "sphinx"])
3736
captured = capsys.readouterr()
38-
assert f"{_exe_if_win("uv")} pip install" in caplog.text
37+
assert "uv" in caplog.text
3938
assert "installed package" in captured.out
4039

4140

4241
def test_custom_installer_backend_uv(pipx_temp_env, capsys, caplog):
4342
assert not run_pipx_cli(["install", "--installer", "uv", "--backend", "uv", "black"])
4443
captured = capsys.readouterr()
45-
assert f"{_exe_if_win("uv")} venv" in caplog.text
46-
assert f"{_exe_if_win("uv")} pip install" in caplog.text
44+
assert f"{'uv.EXE' if WIN else 'uv'} venv" in caplog.text
45+
assert "uv pip install" in caplog.text
4746
assert "installed package" in captured.out
4847

4948

5049
def test_custom_installer_uv_backend_venv(pipx_temp_env, capsys, caplog):
5150
assert not run_pipx_cli(["install", "--installer", "uv", "--backend", "venv", "nox"])
5251
captured = capsys.readouterr()
5352
assert "-m venv --without-pip" in caplog.text
54-
assert f"{_exe_if_win("uv")} pip install" in caplog.text
53+
assert f"{'uv.EXE' if WIN else 'uv'} pip install" in caplog.text
5554
assert "installed package" in captured.out
5655

5756

5857
def test_custom_installer_uv_backend_virtualenv(pipx_temp_env, capsys, caplog):
5958
assert not run_pipx_cli(["install", "--installer", "uv", "--backend", "virtualenv", "pylint"])
6059
captured = capsys.readouterr()
61-
assert f"{_exe_if_win("virtualenv")} --python" in caplog.text
62-
assert f"{_exe_if_win("uv")} pip install" in caplog.text
60+
assert "virtualenv" in caplog.text
61+
assert f"{'uv.EXE' if WIN else 'uv'} pip install" in caplog.text
6362
assert "installed package" in captured.out
6463

6564

6665
def test_custom_installer_pip_backend_uv(pipx_temp_env, capsys, caplog):
6766
assert not run_pipx_cli(["install", "--installer", "pip", "--backend", "uv", "nox"])
6867
captured = capsys.readouterr()
69-
assert f"{_exe_if_win("uv")} venv" in caplog.text
68+
assert f"{'uv.EXE' if WIN else 'uv'} venv" in caplog.text
7069
assert "-m pip" in caplog.text
7170
assert "installed package" in captured.out
7271

0 commit comments

Comments
 (0)