meta_package_manager.managers.pipx module¶

class meta_package_manager.managers.pipx.Pipx[source]¶

Bases: PackageManager

pipx installs Python CLI applications, each in its own isolated venv.

Installed applications come from pipx list --json; only each venv’s main package is tracked, never the packages injected beside it. There is no search operation: the request was closed as not planned, since PyPI exposes no search API and custom search is out of pipx’s scope (see pypa/pipx#777).

Note

The outdated query prefers pipx 1.16.0’s native pipx list --outdated, which checks every venv in one call, each against its own backend (pip or uv). An older pipx falls back to probing each venv with its embedded pip, one call per application. The version floor stays at 1.0.0 so an older pipx remains fully usable: only the outdated path degrades.

Note

The supply-chain cooldown rides on the underlying pip and needs that pip to be at least 26.1, the first release to honor --uploaded-prior-to; older pip silently ignores the release-age gate.

Initialize cli_errors list.

name: str = 'Python pipx'¶

Return package manager’s common name.

Default value is based on class name.

homepage_url: str | None = 'https://pipx.pypa.io'¶

Home page of the project, only used in documentation for reference.

Slug of the brand mark standing for this manager in the documentation.

Names an SVG vendored under docs/assets/managers/, whose provenance and license are recorded in docs/assets/managers/logos.yaml. Inlined at the top of the manager’s page by meta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.

Several managers legitimately share one slug, either because they wrap the same upstream (brew and cask) or because the tool has no mark of its own and its ecosystem’s stands in (apt under Debian’s swirl, cargo under Rust’s gear). Documentation-only, like homepage_url: no CLI output reads it.

platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='aix', name='IBM AIX'), Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='cygwin', name='Cygwin'), Platform(id='debian', name='Debian'), Platform(id='dragonfly_bsd', name='DragonFly BSD'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='freebsd', name='FreeBSD'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='haiku', name='Haiku'), Platform(id='hurd', name='GNU/Hurd'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='illumos', name='illumos'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='macos', name='macOS'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='midnightbsd', name='MidnightBSD'), Platform(id='netbsd', name='NetBSD'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='openbsd', name='OpenBSD'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='os400', name='IBM i'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='solaris', name='Solaris'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='sunos', name='SunOS'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='windows', name='Windows'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})¶

List of platforms supported by the manager.

Allows for a mishmash of platforms and groups of platforms. Will be normalized into a frozenset of Platform instances at instantiation.

requirement: str | None = '>=1.0.0'¶
$ pipx --version
1.0.0
cooldown_env_var: ClassVar[str | None] = 'PIP_UPLOADED_PRIOR_TO'¶

pipx defers resolution to pip, so it honors pip’s --uploaded-prior-to gate through the same environment variable.

Setting PIP_UPLOADED_PRIOR_TO on a pipx invocation propagates to the pip subprocess pipx spawns to install the application and its dependencies, so the cutoff applies to the whole resolution. mpm injects the RFC 3339 timestamp from the default meta_package_manager.execution.CLIExecutor.cooldown_env_value().

Caution

Same caveat as meta_package_manager.managers.pip.Pip: the underlying pip must be at least 26.1 for the gate to take effect. Older pip releases silently ignore the env var.

See pypa/pipx#1811.

outdated_requirement = '>=1.16.0'¶

Minimum pipx version providing the native outdated query.

1.16.0 introduced pipx list --outdated (see pypa/pipx#149). Kept apart from requirement (>=1.0.0) so an older pipx stays fully usable, outdated falling back to one pip probe per venv.

property installed: Iterator[Package]¶

Fetch installed packages.

$ pipx list --json
{
  "pipx_spec_version": "0.1",
  "venvs": {
      "pycowsay": {
        "metadata": {
          "injected_packages": {},
          "main_package": {
            "app_paths": [
              {
                "__Path__": "~/.local/pipx/venvs/pycowsay/bin/pycowsay",
                "__type__": "Path"
              }
            ],
            "app_paths_of_dependencies": {},
            "apps": [
              "pycowsay"
            ],
            "apps_of_dependencies": [],
            "include_apps": true,
            "include_dependencies": false,
            "package": "pycowsay",
            "package_or_url": "pycowsay",
            "package_version": "0.0.0.1",
            "pip_args": [],
            "suffix": ""
          },
        "pipx_metadata_version": "0.2",
        "python_version": "Python 3.10.4",
        "venv_args": []
      }
    }
  }
}
property outdated: Iterator[Package]¶

Fetch outdated packages.

pipx 1.16.0 introduced a native outdated query, which checks all venvs in a single call, each against its own backend (pip or uv). Injected packages are excluded by default, so only each venv’s main package is reported. Pinned packages are kept: a newer release exists, even if pipx upgrade skips them.

$ pipx list --outdated --output=json
{
  "command": ["list"],
  "data": {
    "packages_checked": 1,
    "packages": [
      {
        "environment": "pycowsay",
        "package": "pycowsay",
        "version": "0.0.0.1",
        "latest_version": "0.0.0.2",
        "injected": false,
        "pinned": false
      }
    ],
    "skipped": []
  },
  "errors": [],
  "exit_code": 0,
  "pipx_result_version": "1",
  "status": "success"
}

A pipx older than outdated_requirement falls back to probing each venv with its embedded pip, one call per package. Only the venv’s main package is reported; its dependencies also show up in pip list --outdated but are silenced:

$ pipx runpip pycowsay list --no-color --format=json --outdated         > --verbose --quiet
[
  {
    "name": "pycowsay",
    "version": "0.0.0.1",
    "location": "~/.local/pipx/venvs/pycowsay/lib/python3.10/site-packages",
    "installer": "pip",
    "latest_version": "0.0.0.2",
    "latest_filetype": "wheel"
  }
]

Todo

Drop the fallback, which mimics Pip.outdated(), once pipx 1.16.0 is old enough to be required outright.

install(package_id, version=None)[source]¶

Install one package.

$ pipx install pycowsay
installed package pycowsay 0.0.0.1, installed using Python 3.10.4
These apps are now globally available
    - pycowsay
done! ✨ 🌟 ✨
Return type:

str

cli_names: tuple[str, ...] = ('pipx',)¶

List of CLI names the package manager is known as.

This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.

..hint::

This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named python or python3.

By default, this property’s value is derived from the manager’s ID (see the MetaPackageManager.__init__ method above).

id: str = 'pipx'¶

Package manager’s ID.

Derived by defaults from the lower-cased class name in which underscores _ are replaced by dashes -.

This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.

upgrade_all_cli()[source]¶

Upgrade all packages.

Return type:

tuple[str, ...]

virtual: bool = False¶

Should we expose the package manager to the user?

Virtual package manager are just skeleton classes used to factorize code among managers of the same family.

upgrade_one_cli(package_id, version=None)[source]¶

Upgrade the package provided as parameter.

Return type:

tuple[str, ...]

remove(package_id)[source]¶

Remove one package.

$ pipx uninstall pycowsay
uninstalled pycowsay! ✨ 🌟 ✨
Return type:

str