# pipx



#### Installation:

```bash
$ brew install pipx
$ pipx ensurepath
```



#### Complétions:

Ajouter à `.zshrc`:

```bash
autoload -U bashcompinit && bashcompinit
eval "$(register-python-argcomplete pipx)"
```



#### Installer un paquet:

```bash
$ pipx install soco-cli
```

Le paquet est installé dans un environnement virtuel sous `~/.local/pipx/venvs`

```bash
~/.local/pipx/venvs/soco-cli/bin                                                            
$ ls -la
Permissions  Size User  Group Date Modified Date Created Name
.rw-r--r--  1,9Ki bruno staff 17 aoû 10:47  17 aoû 10:47  activate
.rw-r--r--    867 bruno staff 17 aoû 10:47  17 aoû 10:47  activate.csh
.rw-r--r--  2,0Ki bruno staff 17 aoû 10:47  17 aoû 10:47  activate.fish
.rw-r--r--  8,6Ki bruno staff 17 aoû 10:47  17 aoû 10:47  Activate.ps1
.rwxr-xr-x    278 bruno staff 17 aoû 10:47  17 aoû 10:47  normalizer*
lrwxr-xr-x      9 bruno staff 17 aoû 10:47  17 aoû 10:47  python@
lrwxr-xr-x      9 bruno staff 17 aoû 10:47  17 aoû 10:47  python3@
lrwxr-xr-x     42 bruno staff 17 aoû 10:47  17 aoû 10:47  python3.9@
.rwxr-xr-x    247 bruno staff 17 aoû 10:47  17 aoû 10:47  soco*
.rwxr-xr-x    256 bruno staff 17 aoû 10:47  17 aoû 10:47  soco-discover*
.rwxr-xr-x    250 bruno staff 17 aoû 10:47  17 aoû 10:47  soco-http-api-server*
.rwxr-xr-x    247 bruno staff 17 aoû 10:47  17 aoû 10:47  sonos*
.rwxr-xr-x    256 bruno staff 17 aoû 10:47  17 aoû 10:47  sonos-discover*
.rwxr-xr-x    250 bruno staff 17 aoû 10:47  17 aoû 10:47  sonos-http-api-server*
.rwxr-xr-x    243 bruno staff 17 aoû 10:47  17 aoû 10:47  tabulate*
.rwxr-xr-x    245 bruno staff 17 aoû 10:47  17 aoû 10:47  uvicorn*
```

Les applis sont linkées dans `$HOME/.local/bin`

```bash
$ which soco
/Users/bruno/.local/bin/soco
```



```bash
$ pipx install 'glances[action,browser,cloud,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi]'
```



#### Installer un paquet avec une version précise de python:

```bash
$ pipx install mac-cleanup --python /opt/homebrew/opt/python@3.11/libexec/bin/python3
```



#### Exécuter un paquet sans l'installer:

```bash
$ pipx run pycowsay Meuuuhh !
⚠️  pycowsay is already on your PATH and installed at /Users/bruno/.local/bin/pycowsay. Downloading and running anyway.

  ---------
< Meuuuhh ! >
  ---------
   \   ^__^
    \  (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||

```



#### Liste des paquets installés:

```bash
$ pipx list
venvs are in /Users/bruno/.local/pipx/venvs
apps are exposed on your $PATH at /Users/bruno/.local/bin
   package pycowsay 0.0.0.1, Python 3.9.6
    - pycowsay
   package soco-cli 0.4.15, Python 3.9.6
    - soco
    - soco-discover
    - soco-http-api-server
    - sonos
    - sonos-discover
    - sonos-http-api-server
```

Avec les paquets additionnels:

```bash
$ pipx list --include-injected
venvs are in /Users/bruno/.local/pipx/venvs
apps are exposed on your $PATH at /Users/bruno/.local/bin
   package mkdocs 1.2.2, Python 3.9.6
    - mkdocs
    Injected Packages:
      - fontawesome-markdown 0.2.6
      - mkdocs-git-revision-date-localized-plugin 0.9.2
      - mkdocs-material 7.2.4
      - mkdocs-material-extensions 1.0.1
      - mkdocs-minify-plugin 0.4.0
      - mkdocs-pdf-export-plugin 0.5.8
   package pycowsay 0.0.0.1, Python 3.9.6
    - pycowsay
```



#### Installer un paquet dans un environnement virtuel:

```bash
$ pipx inject mkdocs mkdocs-material mkdocs-material-extensions mkdocs-minify-plugin  mkdocs-git-revision-date-localized-plugin mkdocs-pdf-export-plugin fontawesome_markdown markdown pymdown-extensions

  injected package mkdocs-material into venv mkdocs
done! ✨ 🌟 ✨
  injected package mkdocs-material-extensions into venv mkdocs
done! ✨ 🌟 ✨
  injected package mkdocs-minify-plugin into venv mkdocs
done! ✨ 🌟 ✨
  injected package mkdocs-git-revision-date-localized-plugin into venv mkdocs
done! ✨ 🌟 ✨
  injected package mkdocs-pdf-export-plugin into venv mkdocs
done! ✨ 🌟 ✨
  injected package fontawesome-markdown into venv mkdocs
done! ✨ 🌟 ✨
  injected package markdown into venv mkdocs
done! ✨ 🌟 ✨
  injected package pymdown-extensions into venv mkdocs
done! ✨ 🌟 ✨

```



#### Mise-à-jour:

```bash
$ pipx upgrade soco-cli
soco-cli is already at latest version 0.4.15 (location: /Users/bruno/.local/pipx/venvs/soco-cli)
```

Mettre également à jour les paquets additionnels:

```bash
$ pipx upgrade mkdocs --include-injected
mkdocs is already at latest version 1.2.2 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
fontawesome-markdown is already at latest version 0.2.6 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
mkdocs-git-revision-date-localized-plugin is already at latest version 0.9.2 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
mkdocs-material is already at latest version 7.2.4 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
mkdocs-material-extensions is already at latest version 1.0.1 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
mkdocs-minify-plugin is already at latest version 0.4.0 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
mkdocs-pdf-export-plugin is already at latest version 0.5.8 (location: /Users/bruno/.local/pipx/venvs/mkdocs)
```

```bash
$ pipx upgrade-all
Versions did not change after running 'pip upgrade' for each package 😴
```



#### Désinstaller:

```bash
$ pipx uninstall glances
uninstalled glances! ✨ 🌟 ✨
```



#### Reinstaller:

En réinstallant un paquet, on met aussi à jour sa version de Python.

```bash
$ pipx list
package pycowsay 0.0.0.1, installed using Python 3.9.6
    - pycowsay
```

```bash
$ pipx reinstall pycowsay
uninstalled pycowsay! ✨ 🌟 ✨
  installed package pycowsay 0.0.0.1, installed using Python 3.10.2
  These apps are now globally available
    - pycowsay
done! ✨ 🌟 ✨
```



#### Aide:

```bash
$ pipx --help
$ pipx <commande> --help
```



The HTML specification is maintained by the W3C.

--8<-- "includes/abbreviations.md"
