mafw.devtools.toolchain.tools.uv

Concrete HostTool implementation for uv.

uv is a host tool installed system-wide via pipx. Its version must stay in sync with the hatch-uv dependency declared in pyproject.toml under [tool.hatch.envs.hatch-uv].

Update logic:

  1. Run pipx upgrade uv (via update()) to bring the pipx installation to the latest version.

  2. Update the lower-bound specifier for uv in the hatch-uv environment dependencies section of pyproject.toml.

Verification logic:

Compare the pipx-installed version against the specifier declared in pyproject.toml and report an Issue if the installed version does not satisfy the declared constraint.

Classes

UvTool([pyproject_path])

Toolchain management for the uv package manager.

class mafw.devtools.toolchain.tools.uv.UvTool(pyproject_path: Path = PosixPath('pyproject.toml'))[source]

Bases: HostTool

Toolchain management for the uv package manager.

uv is installed as a host tool via pipx and its version specifier is additionally tracked in pyproject.toml under the hatch-uv hatch environment so that hatch uses a compatible uv version.

All common host-tool operations (bootstrap, version detection, PyPI queries) are inherited from HostTool. This subclass overrides update() to additionally synchronize the pyproject.toml specifier and verify() to check specifier satisfaction.

Parameters:

pyproject_path (Path) – Path to the pyproject.toml file. Defaults to pyproject.toml in the current working directory.

update() bool[source]

Upgrade uv via pipx and update the pyproject.toml specifier.

Performs two operations:

  1. Delegates to update() which runs pipx upgrade uv and checks if the version changed.

  2. If the version changed, updates the lower-bound version specifier for uv in the [tool.hatch.envs.hatch-uv] dependencies section of pyproject.toml.

Returns:

True if the version changed, False if already up to date.

Raises:

DevtoolsError – If pipx is not available, the upgrade fails, or the pyproject.toml modification fails.

verify() list[Issue][source]

Check that the pipx-installed uv satisfies the declared specifier.

Compares the version installed via pipx against the version specifier declared in pyproject.toml under [tool.hatch.envs.hatch-uv].

Returns:

A list containing one Issue if the versions are out of sync, or an empty list if consistent.

property pipx_package_name: str

The pipx package name for uv.

mafw.devtools.toolchain.tools.uv._extract_specifier_from_requirement(requirement: str) str[source]

Extract the version specifier portion from a PEP 508 requirement string.

Given a string like "uv>=0.10" or "uv>0.10,<1.0", returns the specifier portion (e.g. ">=0.10" or ">0.10,<1.0").

Parameters:

requirement (str) – A raw PEP 508 requirement string.

Returns:

The specifier portion of the requirement.

Return type:

str

mafw.devtools.toolchain.tools.uv._HATCH_UV_SECTION: str = 'tool.hatch.envs.hatch-uv.dependencies'

Section path in pyproject.toml where the uv dependency is declared.

mafw.devtools.toolchain.tools.uv._PYPROJECT_PATH: Path = PosixPath('pyproject.toml')

Default path to the project’s pyproject.toml file.