diff --git a/knowledge base/pip.md b/knowledge base/pip.md index a9d1f1f..a738cd7 100644 --- a/knowledge base/pip.md +++ b/knowledge base/pip.md @@ -40,12 +40,12 @@ pip-autoremove INI format files, on those levels: -Level | Scope | File locations ----|---|--- -global | System-wide, shared | The `pip` subdirectory in any of the directories defined in `XDG_CONFIG_DIRS` if it exists (i.e. `/etc/xdg/pip/pip.conf`)
`/etc/pip.conf` -user | Per-user | `$HOME/.config/pip/pip.conf`
`$HOME/.pip/pip.conf` (legacy) -site | Per-environment | `$VIRTUAL_ENV/pip.conf` -shell | Active shell session | Value of `PIP_CONFIG_FILE` +| Level | Scope | File locations | +| ------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| global | System-wide, shared | The `pip` subdirectory in any of the directories defined in `XDG_CONFIG_DIRS`, if it exists (i.e. `/etc/xdg/pip/pip.conf`)
`/etc/pip.conf` | +| user | Per-user | `$HOME/.config/pip/pip.conf`
`$HOME/.pip/pip.conf` (legacy) | +| site | Per-environment | `$VIRTUAL_ENV/pip.conf` | +| shell | Active shell session | Value of `PIP_CONFIG_FILE` | When multiple configuration exist, pip **merges** them in the following order: @@ -59,6 +59,7 @@ Latter files override values from previous files, i.e. the global timeout specif ## Further readings - [Configuration] +- [`pipx`][pipx] [configuration]: https://pip.pypa.io/en/stable/topics/configuration/ + + +[pipx]: pipx.md diff --git a/knowledge base/pipx.md b/knowledge base/pipx.md new file mode 100644 index 0000000..cd56107 --- /dev/null +++ b/knowledge base/pipx.md @@ -0,0 +1,57 @@ +# Pipx + +Tool to help install and run end-user applications written in Python. + +It acts as a package manager using [`pip`][pip] behind the scenes, but is focused on installing and managing Python packages that can be run from the command line directly as applications. + +The `install` command automatically creates a Python virtual environment, installs the package, and adds the package's associated applications (entry points) to a location in PATH. For this reason, `pipx` never needs to run as `root`.
+For example, `pipx install 'pycowsay'` makes the `pycowsay` command available globally, but sandboxes the package in its own virtual environment. + +## Table of contents + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) + +## TL;DR + +```sh +# Installation. +python3 -m pip install --user 'pipx' +brew install 'pipx' + +# Add pipx's binary folders to PATH. +pipx ensurepath +python3 -m pipx ensurepath + +# Install applications. +pipx install 'ansible' + +# List installed applications. +pipx list + +# Run applications *without* installing them globally. +pipx run 'xkcdpass' +pipx run --spec 'package' 'app_with_different_name_in_the_package' +pipx run 'yamllint==1.31.0' + +# Upgrade single applications. +pipx upgrade 'pip-autoremove' + +# Upgrade all installed applications. +pipx upgrade-all +``` + +## Further readings + +- [Website] +- [Pip] + + + + +[website]: https://pypa.github.io/pipx/ + + +[pip]: pip.md diff --git a/knowledge base/python.md b/knowledge base/python.md index c30b832..7863086 100644 --- a/knowledge base/python.md +++ b/knowledge base/python.md @@ -183,6 +183,7 @@ See [concurrent execution] for more information. - [Dictionaries] - [PIP] +- [`pipx`][pipx] - [How To Update All Python Packages] - [invl/pip-autoremove] - [Data types] @@ -199,6 +200,8 @@ See [concurrent execution] for more information. ## Sources +All the references in the [further readings] section, plus the following: + - [10 python one-liners for dictionaries] - [Logging library] - [Subprocess library] @@ -215,7 +218,11 @@ See [concurrent execution] for more information. [subprocess library]: https://docs.python.org/3/library/subprocess.html +[further readings]: #further-readings + + [pip]: pip.md +[pipx]: pipx.md [*args and **kwargs in python]: https://www.geeksforgeeks.org/args-kwargs-python/