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:
Run
pipx upgrade uv(viaupdate()) to bring the pipx installation to the latest version.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
|
Toolchain management for the uv package manager. |
- class mafw.devtools.toolchain.tools.uv.UvTool(pyproject_path: Path = PosixPath('pyproject.toml'))[source]
Bases:
HostToolToolchain 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-uvhatch 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 overridesupdate()to additionally synchronize the pyproject.toml specifier andverify()to check specifier satisfaction.- Parameters:
pyproject_path (Path) – Path to the
pyproject.tomlfile. Defaults topyproject.tomlin the current working directory.
- update() bool[source]
Upgrade uv via pipx and update the pyproject.toml specifier.
Performs two operations:
Delegates to
update()which runspipx upgrade uvand checks if the version changed.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:
Trueif the version changed,Falseif 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
Issueif 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.