meta_package_manager.managers.uv module¶

class meta_package_manager.managers.uv.UVBase[source]¶

Bases: PackageManager

Virtual base shared by the UV and UVX managers defined below.

Initialize cli_errors list.

homepage_url: str | None = 'https://docs.astral.sh/uv'¶

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.

requirement: str | None = '>=0.5.0'¶

0.5.0 is the first version to introduce pip list --outdated command.

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.

virtual: bool = True¶

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.

cooldown_env_var: ClassVar[str | None] = 'UV_EXCLUDE_NEWER'¶

uv honors a release-age cooldown through its exclude-newer resolver option.

UV_EXCLUDE_NEWER mirrors the --exclude-newer flag and is read by every resolving subcommand (pip install, pip list --outdated, tool install, tool upgrade), so a single environment variable covers install, upgrade and outdated at once. uv accepts an RFC 3339 timestamp, which is exactly what the default meta_package_manager.execution.CLIExecutor.cooldown_env_value() produces.

Note

The environment variable is the only mechanism that reaches these subcommands, which is why the cutoff is injected rather than written to a config file. uv pip and uv tool operate at the user level and ignore project-local configuration: a [tool.uv] table in the pyproject.toml of whatever directory the user happens to stand in is never consulted. Only user-level and system-level uv.toml are, and UV_EXCLUDE_NEWER outranks both.

Caution

Because the variable outranks those files, injecting it replaces any standing exclude-newer the user configured rather than tightening it: a cooldown looser than their own policy silently widens it for the duration of the run. See Cooldown, section “The cooldown is authoritative, not a floor”.

uv exposes no environment variable for the companion --exclude-newer-package flag, so a per-package exemption cannot be injected the way this cutoff is.

See uv’s exclude-newer setting.

pre_args: tuple[str, ...] = ('--color', 'never', '--no-progress')¶
  • --color color-choice

    Control colors in output [default: auto]

    Possible values: - auto: Enables colored output only when the output is going to a terminal or TTY with support - always: Enables colored output regardless of the detected environment - never: Disables colored output

  • --no-progress

    Hide all progress outputs.

    For example, spinners or progress bars.

version_regexes: tuple[str, ...] = ('uv\\s+(?P<version>\\S+)',)¶
$ uv --version
uv 0.2.21 (ebfe6d8fc 2024-07-03)
cli_names: tuple[str, ...] = ('uvbase',)¶

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 = 'uvbase'¶

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.

name: str = 'UVBase'¶

Return package manager’s common name.

Default value is based on class name.

class meta_package_manager.managers.uv.UV[source]¶

Bases: UVBase

Python packages managed with uv’s uv pip interface.

Installed and outdated packages are read with uv pip list (adding --outdated and --format=json), acting on whatever environment uv resolves, exactly as a bare uv pip call in the same shell would. The --outdated listing sets the >=0.5.0 version floor, the first uv release to ship it. The release-age cooldown rides on uv’s --exclude-newer resolver option, which every resolving subcommand honors, so one cutoff covers install, upgrade and outdated together.

Hint

Package specs are passed unquoted, working around uv parse failures on quoted specs.

Initialize cli_errors list.

name: str = 'Python uv'¶

Return package manager’s common name.

Default value is based on class name.

property installed: Iterator[Package]¶

Fetch installed packages.

$ uv --color never --no-progress pip list --format=json
[
  {
    "name": "markupsafe",
    "version": "2.1.5"
  },
  {
    "name": "meta-package-manager",
    "version": "5.17.0",
    "editable_project_location": "/Users/kde/meta-package-manager"
  },
  {
    "name": "myst-parser",
    "version": "3.0.1"
  }
]
property outdated: Iterator[Package]¶

Fetch outdated packages.

$ uv --color never --no-progress pip list --outdated --format=json
[
  {
    "name": "lark-parser",
    "version": "0.7.8",
    "latest_version": "0.12.0",
    "latest_filetype": "wheel"
  },
  {
    "name": "types-setuptools",
    "version": "75.3.0.20241107",
    "latest_version": "75.3.0.20241112",
    "latest_filetype": "wheel"
  }
]
install(package_id, version=None)[source]¶

Install one package.

$ uv --color never --no-progress pip install arrow
Return type:

str

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

Generates the CLI to upgrade the package provided as parameter.

$ uv --color never --no-progress pip install --upgrade arrow
Return type:

tuple[str, ...]

remove(package_id)[source]¶

Remove one package.

$ uv --color never --no-progress pip uninstall arrow
Return type:

str

cleanup_cache()[source]¶

Removes things we don’t need anymore.

Warning

Skipped when mpm itself was launched by uv run or uvx: the parent uv process keeps a lock on its cache for as long as its child lives, so each cache command below would wait on its own ancestor for UV_LOCK_TIMEOUT (300 seconds by default), fail, and stall the whole cleanup for ten minutes. uv advertises itself to its children through the UV environment variable, which is the marker detected here.

$ uv --color never --no-progress cache clean
Clearing cache at: /Users/kde/Library/Caches/uv
Removed 97279 files (2.0GiB)
$ uv --color never --no-progress cache prune
No cache found at: /Users/kde/.cache/uv
Return type:

None

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

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 = 'uv'¶

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.

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.

class meta_package_manager.managers.uv.UVX[source]¶

Bases: UVBase

uv’s tool manager for isolated Python applications, like pipx.

mpm drives the uv tool subcommands; each application lives in its own venv. Installed and outdated tools are parsed from the plain-text tool list and tool list --outdated output: unlike the uv pip interface, uv tool emits no JSON. The --outdated listing sets the >=0.10.10 version floor, the first uv release to ship it. The release-age cooldown rides on uv’s --exclude-newer resolver option, covering install, upgrade and outdated through one cutoff.

Hint

Package specs are passed unquoted, working around uv parse failures on quoted specs.

Initialize cli_errors list.

name: str = 'Python uvx'¶

Return package manager’s common name.

Default value is based on class name.

homepage_url: str | None = 'https://docs.astral.sh/uv/guides/tools/'¶

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

brewfile_entry_type: ClassVar[str | None] = 'uv'¶

Mapped to Homebrew Bundle’s uv entry type, which installs via uv tool install: the same mechanism UVX wraps, while the pip-style UV manager has no Brewfile counterpart. See Snapshot and export, section “uv mapping”.

requirement: str | None = '>=0.10.10'¶

0.10.10 is the first version to introduce tool list --outdated command.

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

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 = 'uvx'¶

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.

property installed: Iterator[Package]¶

Fetch installed packages.

$ uv --color never --no-progress tool list
pycowsay v0.0.0.1
- pycowsay
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.

property outdated: Iterator[Package]¶

Fetch outdated packages.

$ uv --color never --no-progress tool list --outdated
pycowsay v0.0.0.1 [latest: 0.0.0.2]
- pycowsay
install(package_id, version=None)[source]¶

Install one package.

$ uv --color never --no-progress tool install pycowsay
Return type:

str

upgrade_all_cli()[source]¶

Generates the CLI to upgrade all packages.

$ uv --color never --no-progress tool upgrade --all
Updated pycowsay v0.0.0.1 -> v0.0.0.2
    - pycowsay
Return type:

tuple[str, ...]

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

Generates the CLI to upgrade the package provided as parameter.

$ uv --color never --no-progress tool upgrade pycowsay
Return type:

tuple[str, ...]

remove(package_id)[source]¶

Remove one package.

$ uv --color never --no-progress tool uninstall pycowsay
Return type:

str